On 24 Feb 2009, at 14:00, Valentino Lun wrote:
>
> user = {:username => "123", :display_name => "345"}
> => {:username=>"123", :display_name=>"345"}
>
> a = User.new(user)
> => #<User username: nil, display_name: "345">
>
> Why the username field is nil instead of "123"? I also tried
> {:id=>"123", :display_name=>"345"}, still not work
>
> But there is no problem when I do the following
> a.username = "123" or a.id = "123"
> a.save
>
> Please help. Thank you very much.
>
Because the primary key is protected from mass assignment.

Fred
> Valentino
> --  
> Posted via http://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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to