Search Results

Search found 1 results on 1 pages for 'hb922'.

Page 1/1 | 1 

  • inheriting scope from a has_many relationship

    - by hb922
    I am using ruby on rails 3.1 and have 2 models, an event and a group. Each event has_many groups, but has to have at least one "master" group, where the column :is_master = true Class Group < ActiveRecord::Base has_many :users belongs_to :event scope :master, where (:is_master => true) end Class Event< ActiveRecord::Base has_many :groups def master_group groups.master end end I want to be able to default all properties of the master group to the event, so for example, event.users.count should be the same as event.master_group.users.count. Is there any way to do something like this? Can I do a has_many :through = master_group? Am I approaching this the wrong way? Thanks!

    Read the article

1