开发者

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.

  1. The form (index) has this line:
'xlsexport( :filename => "testing", worksheet => "the sheet")' %>

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.

  1. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜