Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8576559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:57:04+00:00 2026-06-11T19:57:04+00:00

I have problems displaying error_messages.html.erb partial when building custom validation. I have for instance,

  • 0

I have problems displaying error_messages.html.erb partial when building custom validation.

I have for instance, a form to make a transaction, which starts like:

<%= form_for @transaction do |f| %>
  <%= render 'shared/error_messages', :object => f.object %>

I have a validation which prevents a user from making a transaction with himself:

validate :self_transaction_not_possible

with

    def self_transaction_not_possible
      bel = Belonging.find_by_id(self.belonging.id)
      unless bel.nil?
        if self.user_id == bel.user_id
          errors.add(:base, "You cannot perform a transaction with yourself")
        end
      end
    end 

Then I ran such an example in the browser (initiate a transaction on a belonging I own), and I placed a debugger inside self_transaction_not_possible. I checked that the validation happens, and indeed, inside the debugger, I see that typing: self.errors.full_messages give me my error message, so validation seems to be performed…

I would then have expected, as the object was not valid, that the error message would appear in my view, but no … putting the debugger inside the error_messages.html.erb partial showed me that object.errors.any remains == {} :-/ …

The user is then redirected towards the page it should see when the saving process fails (validation has been performed correctly), but he never sees the error message …

Am I missing something obvious ? …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:57:05+00:00Added an answer on June 11, 2026 at 7:57 pm

    OK … the reason it failed was because I was doing a REDIRECT_TO in the controller when the transaction was not being saved, thereby deleting the @transaction.errors vector …

    Changing this to a render :template => 'transactions/edit' solved my issue ..

    Of course, it was hard to guess looking at the question :-/ …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem displaying validation errors that are triggered by ui components which
I'm generating dynamic HTML inside Delphi. I have no problem displaying UTF-8 strings inside
I have created a custom module in magento which contains a textbox and an
We have an MS Access 2007 database with a simple form displaying table data.
I have a partial view (ascx) for displaying the top x articles of a
I have an MVC 3 application and am trying to display a custom validation
I have problem with displaying adsense ads in ie7 google adsense adds an iframe
I have a problem displaying non- ASCII characters in Matplotlib, these characters are rendered
I have a problem displaying zebra list after filtering results. I have a zebra
I have some problem with displaying emoji icon in Android TextView First, I found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.