开发者

Rails 3: Is there anything wrong with the syntax for my named scope?

开发者 https://www.devze.com 2023-02-28 21:40 出处:网络
Is there anything wrong with the syntax for my named scope?Because it ain\'t workin... scope 开发者_如何学运维:that_is_registered_in_tournament_with_username, lambda { |tourney_id, name| where(\"user

Is there anything wrong with the syntax for my named scope? Because it ain't workin...

scope 开发者_如何学运维:that_is_registered_in_tournament_with_username, lambda { |tourney_id, name| where("username = ? and tournament_id = ?", name, tourney_id).first }

Thanks so much!


I think the problem is first. First actually picks the first object from a given relation. Thus, it's actually an object and not a relation. I think that if you lose .first, it will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号