I am doing the following:
@group_coach = GroupCoach.find("groups_count < '9'" )
I have a groups_count column in my db that is being updated by a counter_cache => true method in the Group model.
I know this isn't right. Because the error it spits out: Couldn't find GroupCoach with ID=groups_count < '9'
I have reviewed the Rails Guides:
client = Client.find(10)
Client.where("orders_count = '2'")
The second option does run in the localhost but isn't开发者_运维技巧 actually returning a GroupCoach... It just returns groupcoach...
What is the proper syntax for this?
Have you tried:
@group_coach = GroupCoach.where("groups_count < 9")
To clarify: @group_coach
will be a collection of records. So you can't call @group_coach.name
because all that will do is give you "GroupCoach" (the name of the class). Instead, you would need to iterate over the items:
@group_coach.each do |group_coach|
puts group_coach.name
end
精彩评论