I had a strange problem today where my field validation was working, but the standard red error box and red field highlighting was not working.
I have an application that does mailings of PDF files. I have a model called “mailing” and a model called “contact”. I also have a “subscription” model to link the contacts to the mailings and vice versa.
This issue only occured when I was creating new contacts … So I compared my “create” method in the controller for the “mailing” object/model to the “create” method in the controller for the “contact” object/model and figured out the difference …
The problem … in the contacts_controller, in the “create” method I retrieved the contact object as follows:
contact = Contact.new(params[:contact])
When I should have retrieved it as follows:
@contact = Contact.new(params[:contact])
I understand now that the contact object wasn’t made available to the view … I need to read up on the difference between using @ or not …
No Comments Yet