Add new action in rails controller

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.