Skip to content

Instantly share code, notes, and snippets.

@roolo
Created August 1, 2012 14:37
Show Gist options
  • Select an option

  • Save roolo/3227397 to your computer and use it in GitHub Desktop.

Select an option

Save roolo/3227397 to your computer and use it in GitHub Desktop.
How to get mass assignable attributes for model
Loading development environment (Rails 3.2.6)
1.9.2p320 :001 > Game.accessible_attributes
=> #<ActiveModel::MassAssignmentSecurity::WhiteList: {"", "name"}>
1.9.2p320 :002 > Game.accessible_attributes.to_a
=> ["", "name"]
1.9.2p320 :003 > Game.accessible_attributes.to_a.reject{|i| i.empty?}
=> ["name"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment