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