Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # in moviegoer.rb:
- class Moviegoer
- has_many :reviews
- has_many :movies, :through => :reviews
- # ...other moviegoer model code
- end
- alice = Moviegoer.find_by_name('Alice')
- alice_movies = alice.movies
- # MAY work, but a bad idea - see caption:
- alice.movies << Movie.find_by_name('Inception') # Don't do this!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement