Guest User

Untitled

a guest
Jul 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. class Article < ActiveRecord::Base
  2. belongs_to :author
  3.  
  4. def before_save
  5. if self.author.name == "Sam"
  6. # Do stuff
  7. end
  8. end
  9.  
  10. class Author < ActiveRecord::Base
  11. has_many :articles
  12. accepts_nested_attributes_for: articles
  13.  
  14. end
  15.  
  16. controller is standard, both models are being created at the same time.
Add Comment
Please, Sign In to add comment