Created
July 9, 2013 19:25
-
-
Save tibbon/5960439 to your computer and use it in GitHub Desktop.
Attr Accessible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These are you Rails models, stored in
app/model