Question

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.

Était-ce utile?

La solution

This should work:

@users = User.find_by_sql( ["SELECT * FROM users ..."])
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top