I have a Rails 3 app which JSON encodes objects in order to store them in a Redis key/value store.
When I retrieve the objects, I\'m trying to decode the JSON and in
assign_attributes
with without_protection: true
seems less intrusive:
user = User.new
user.assign_attributes({ :name => 'Josh', :is_admin => true }, :without_protection => true)
user.name # => "Josh"
user.is_admin? # => true
@tovodeverett mentioned in the comment you can also use it with new
, like this in 1 line
user = User.new({ :name => 'Josh', :is_admin => true }, :without_protection => true)