You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 17, 2025. It is now read-only.
In my ApplicationController, I have a generic index action [that can be overridden by any controller] where I want to return the CSV for any object with something like this:
def index
@records = apply_page_query_parameters(policy_scope(resource_class))
respond_to do |format|
format.html { render_records(@records) }
format.csv {
report = GenericReport.new(project: @all_records, table: resource_class)
send_data generate_csv_from_report(report.results)
}
end
end
But I can't seem to figure out how to pass in that table parameter, which I'd like to use in a GenericReport class kind of like this:
class GenericReport < Dossier::Report
def sql
'SELECT * FROM table <= :table'
end
end
Would appreciate some help! And while I'm here, is there a way to generate the CSV from a report object directly? I wrote the generate_csv_from_report function myself in a helper I created. It was a very small and simple method, but it would be nice to eliminate it entirely.
For the record, the reason I do this instead of redirecting to the dossier reports route is that it was far easier to authorize access to a report this way when using the pundit gem.