Skip to content

Instantly share code, notes, and snippets.

@tibbon
Created July 9, 2013 19:25
Show Gist options
  • Save tibbon/5960439 to your computer and use it in GitHub Desktop.
Save tibbon/5960439 to your computer and use it in GitHub Desktop.
Attr Accessible
class Book < ActiveRecord::Base
# Other stuff should go up here, the following is an example of attr_accessible to allow mass assignment
# Mass assignment is when you do something like Book.create(title: "1984")
attr_accessible :title
end
class Store < ActiveRecord::Base
# Here's another example of attr_accessible to allow mass-assignment
# Non-mass assignment would look like the following:
# store = Store.new
# store.name = "Amazon"
# store.save
# But if you want to do Store.create(name: "Barnes and Nobel")
# You would need the following:
attr_accessible :name
end
@tibbon
Copy link
Author

tibbon commented Jul 9, 2013

These are you Rails models, stored in app/model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment