That gets around the original problem of the initial display but the
error_messages_for method doesn’t appear to be able to handle the
instance variable target_list.
The controller method [ let’s call it x ] that my page posts to has the
following code
def x
@target_list = TargetList.create() @target_list.name = name @target_list.save!
…
and my model for TargetList has
:validates_presence_of :name
So, if I call x based on the post from my form which includes
I get an ugly “Record Invalid” message when I call save! instead of the
error_messages_for output.
Does this not work because the initial definition of the @target_list
instance variable in the controller is within method x?
I wish I could get helper methods to actually work in non-trivial cases.
I'm not trying to use a scaffold to do my model managmeent and it seems
to me that _because_ I'm not using a scaffold, I can't take advantage of
any of these helper things.
It’s got an explanation of the Errors object there and how it gets
loaded on
validation.
When I have a behind-the-scenes question, I use the API and read the
source
for the functions I’m interested in. That really helps me to know
what’s
actually happening, plus I get to see cool Ruby tricks that I didn’t
know
otherwise.
– The Real WG
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.