I have models:
class User < ActiveRecord::Base
has_many :user_skills
end
class UserSkill < ActiveRecord::Base
belongs_to :user
named_scope :rated, :conditions => "count_raters > 0"
end
I want to get count of rated skills.
current_user.user_skills.rated.cont
It works fine, but the generated SQL is a very strange.
SELECT count(*) AS count_all FROM `user_skills` WHERE (((count_raters > 0) AND (`user_skills`.user_id = 988988934)) AND (`user_skills`.user_id = 988988934))
Why does it past twice user_id? How to avoid double passing the user_id field?