如何将find_by_sql转换为named_scope?
我怎样才能变成named_scope?
def self.hero_badge_awardees
return User.find_by_sql("select users.*, awards.*, badges.badge_type
from users, awards, badges
where awards.user_id = users.id and badges.id = awards.badge_id and badges.badge_type = 'HeroBadge'")
end
How can I possibly turn into named_scope?
def self.hero_badge_awardees
return User.find_by_sql("select users.*, awards.*, badges.badge_type
from users, awards, badges
where awards.user_id = users.id and badges.id = awards.badge_id and badges.badge_type = 'HeroBadge'")
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么你可以尝试:
这看起来应该对我有用,但我还没有测试过。希望这能给你带来一些启发。
then you can try:
This looks like it should work to me, but I haven't tested it. Hopefully this sparks something for you though.
要具体回答您的问题,请尝试以下操作:
To specifically answer your question, try this: