Skip to content

Commit

Permalink
Finally, using dynamically created collection_reader_method with new …
Browse files Browse the repository at this point in the history
…GroupedScope::AssociationReflection works well.
  • Loading branch information
metaskills committed Sep 24, 2008
1 parent 20be575 commit ccb540c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/grouped_scope/association_reflection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def verify_ungrouped_reflection
end

def create_grouped_association
active_record.send :has_many, name, options
active_record.send(macro, name, options)
association_proxy_class = options[:through] ? ActiveRecord::Associations::HasManyThroughAssociation : ActiveRecord::Associations::HasManyAssociation
active_record.send(:collection_reader_method, self, association_proxy_class)

active_record.reflections[name] = self
active_record.grouped_scopes[@ungrouped_name] = true
options[:grouped_scope] = true
Expand Down
2 changes: 1 addition & 1 deletion test/grouped_scope/self_grouping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def setup
# raise Employee.reflections[:grouped_scope_reports].inspect
# assert_equal @e1_g1.reports.size, @e1_g1.group.reports.size

@e1_g1.reports
# @e1_g1.reports
# @e1_g1.group.reports
# @e1_g1.grouped_scope_reports
end
Expand Down

0 comments on commit ccb540c

Please sign in to comment.