문제

When I run this line @users = ActiveRecord::Base.connection.execute(raw) I get a mysql result back which I don't feel is as clean or easy to use as a result of actual user objects. Is there a way to covert this result into a array of class User objects? Thanks for the help.

도움이 되었습니까?

해결책

This should work:

@users = User.find_by_sql( ["SELECT * FROM users ..."])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top