Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Article < ActiveRecord::Base
- belongs_to :author
- def before_save
- if self.author.name == "Sam"
- # Do stuff
- end
- end
- class Author < ActiveRecord::Base
- has_many :articles
- accepts_nested_attributes_for: articles
- end
- controller is standard, both models are being created at the same time.
Add Comment
Please, Sign In to add comment