Add new action in rails controller

I’m building a plugin to add new exports in the users section.
Instead to add new controller for every export I would like to extend the ExportCsvController and add new actions to it.
How can I achieve this?

Thanks

1 Like

What problem my are you solving? Could the data explorer plugin solve it?

If not, you can have a look at it, as it adds a route and exports csv.

2 Likes

Thanks for your reply.

I need to create two new exports:

  1. users with membership groups
  2. categories with related groups

I would like to add these two exports inside the ExportCsvController without creating new controller for every export.
Yes, the data explorer could solve the problem but the client for whom I am building the forum is not technical so exporting to CSV is the only way to show him the data.

The plugin is not adding a new method for an existing rails controller but it is creating a new controller for the data explorer logic.

The data explorer plugin will let them download a csv.

And if you want you can automate it by downloading the file directly with the API.

2 Likes

With the Data Explorer plugin, you have a button to export in CVS or JSON (and, recently, even one to show a graph).


You can also allow specific groups to access the query (if we are not talking about admin users here)

Then, the user can see a Reports on the group page. He can run the query, and then he can export the results to CSV.

Would that work?

3 Likes

Yes it can work but the user need to know how to write down a SQL query right?

1 Like

You (the admin) create the SQL, and the user can run the query – the users can’t create or edit.

What the user sees is a list of queries they can run:

3 Likes

Ok thanks, I will try to investigate if this solution can work for our customers. :pray:

3 Likes