How can I use Ransack with "find_by_sql"? I generally do this:
def index
@m = Mymodel.ransack(params[:q])
@mymodels = @m.result.page(params[:page])
end
Can I use Ransack when doing a custom query?:
@mymodels = Mymodel.find_by_sql(["SELECT ... ", current_user])
If I get it correctly, this is want you want:
To answer your question directly though, you can convert it to an SQL string, but you won't (or would be hard) be able to use
current_user
as an argument: