in the *.rb models
Class Profile << ActiveRecord::Base
belongs_to: user
belongs_to: team
named_scope :captain, :conditions => { :role => "captain" }
named_scope :liverpool, :include :team, :conditions => { 'teams.name' => 'liverpool' }
end
This allows following:
user.profile.liverpool #-> finds all user profiles that are in the team liverpool
user.profile.captain #-> finds all user profiles that have the role of captain.
What is a proposition?
vor 15 Jahren
Keine Kommentare:
Kommentar veröffentlichen