Skip to content

Instantly share code, notes, and snippets.

@leflings
Created March 11, 2011 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leflings/866789 to your computer and use it in GitHub Desktop.
Save leflings/866789 to your computer and use it in GitHub Desktop.
class Movie < ActiveRecord::Base
attr_accessible :name, :year, :rating, :watched, :imdb_id
has_many :relationships
has_many :people, :through => :relationships
has_many :roles, :through => :relationships
scope :is_acting, lambda { acting }
scope :is_directing, lambda { directing }
private
def self.acting
where(['relationships.role = ?', "actor"])
end
def self.directing
where(['relationships.role = ?', "director"])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment