Routing: Exporting form to an Excel file
Using Rails 3.0.7.
I have a simple form which shows all records from one table. I would like to have a simple button. If clicked I am exporting the form to an Excel file. The Excel file stuff works. What does not work is the routing.
- The form (index) has this line:
I don't know if this is correct, but what I want to do is to send two arguments to the action xlsexport (c style would be xlsexport("testing","the sheet");) I don't want the user to be able to specify the filename, but I want to be able call the same action from many places with different data.
- Routing seems to have changed several times in rails. So many old examples are incorrect.
The question is, with such a button and an action named xlsexport what route should I have? I thought "match 'simpxl' => 'dailystats#xlsexport'" would be enough, but no. So I tried "match 'simpxl/:filename/:worksheet' => 'dailystats#simpxl'"
开发者_StackOverflow中文版I don't even know if any of this is the right way to do it nowadays? The dailystats class contains both the index and dailystats methods.
match 'dailystats/xlsexport/:filename/:worksheet'
if your controller is dailystats and action is xlsexport.. should work
精彩评论