On Mar 23, 9:31 pm, James Byrne <rails-mailing-l...@andreas-s.net>
wrote:
> I have this controller code:
> ...
> field_array.each do |f|
> f = f.to_sym
> model.send("#{f}=", "#{parm_hash[f]}") if
> model.attribute_present?(f)
> end
> return model
> ...
>
> field_array is an array of attribute names as strings.
> parm_hash is the params hash returned from the view associated with
> model.
>
> If the value associated with an attribute_key is anything but a date
> then this works and the value is set. If the value is a date then it
> sets nil instead.
>
because with a date you can't pull the value from the params hash in
one go like that - there is one value in the hash for each component
(day, month, year). There's more about this at
http://www.spacevatican.org/2008/12/3/dates-params-and-you
Fred
> Can anyone see what I am doing wrong?
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---