I have a groups resource that belongs_to Workouts. Workouts can be public or private and are designated as such by the column share in the workout table (which is an integer and contains a 1 if the workout is public).
I am trying call all groups that are associated with public workouts. I assume this needs to be done through a named_scope but I am unsure of the syntax.
In the groups_controller I am assuming I would call:
@groups = Group.public_groups.all
How should I write the named_scope in Group.rb? (I’m in rails 2.3.8)
named_scope :public_groups, ...
Here’s one way to do it: