Pregunta

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.

¿Fue útil?

Solución

This should work:

@users = User.find_by_sql( ["SELECT * FROM users ..."])
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top