Model Validation & Floating Attributes

Hello all !

I have a model being validated that spits it’s error messages on the
resulting page using:
error_messages_for(:mymodel) … Basic stuff. It’s working perfectly.

Now, I have something else I want to check on the same page (that isn’t
attribute to the Model)… and am trying to add it using:
@mymodel.errors.add_to_base(“another error here”)

However… this doesn’t seem to be working. On the view, the custom
message isn’t being displayed… only the ones from default validation.
When doing an inspect on the model, here is what I see:

#<MyModel:0x4089b20c @errors=#<ActiveRecord::Errors:0x4087fe6c
@errors={“base”=>[“another error here”]}, @base=#<MyModel:0x4089b20c
…>>, @new_record=true, @password_confirmation="", @password="",
@attributes={“created_on”=>Wed Jan 18 16:35:38 PST 2006,
“status”=>true, “birthdate”=>#<Date: 4907507/2,0,2299161>,
“hashed_password”=>nil, “updated_on”=>Wed Jan 18 16:35:38 PST 2006,
“zipcode”=>"", “first_name”=>"", “last_name”=>"", “user_name”=>"",

So, it looks like the custom error is being added to an hash entry
“base” within @errors… while there is another parameter called @base.

If anybody has any insight into this, that would be great.
Thank you !


Nobody has had to do something similar ? This form is basically a
form, with a “captcha” at the bottom… and if they mistype in the
and leave the form blank, I want all the error messages to be uniformly

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs