Domanda

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.

È stato utile?

Soluzione

This should work:

@users = User.find_by_sql( ["SELECT * FROM users ..."])
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top