rails find方法

User.find(
:all,  
:select => "name.*",
:from => "users",
:joins => " inner join role_relations rr on rr.user_group_id = ugn.user_group_id ",
:conditions => "rr.user_id = #{user_id} and ugn.news_id = #{news_id}")

解释成sql语句 select  name.* from users inner join role_relations rr on rr.user_group_id = ugn.user_group_id where rr.user_id = #{user_id} and ugn.news_id = #{news_id}"

你可能感兴趣的:(find)