public
Created

Security Article Part 2 - 6

  • Download Gist
user_creation.rb
Ruby
1 2 3 4 5 6 7 8
User.create!
# -> #<User id: 2, can_do_dangerous_things: false, ...>
 
User.create!(:can_do_dangerous_things => true)
# -> ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: can_do_dangerous_things
 
User.create!(:permissions => {:can_do_dangerous_things => true})
# -> #<User id: 2, can_do_dangerous_things: true, ...>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.