Ignoring extra keys in a hash passed in to create
Posted
by
denniss
on Stack Overflow
See other posts from Stack Overflow
or by denniss
Published on 2011-11-13T01:48:56Z
Indexed on
2011/11/13
1:50 UTC
Read the original article
Hit count: 293
Does rails provide a way to ignore extra keys that are passed in to create. Supposed User has two attributes, first_name and last_name. When I do
User.create({ :first_name => "first", :last_name => "last", :age => 10})
that line gives me an UknonwnAttributeError. Well, that makes sense, it happens cause age is not one of the attributes.
But is there a way to just ignore key-value pair that is not one of the attributes for User?
© Stack Overflow or respective owner