[英]Rails 3. How to setup a controller with custom params?
I create a controller to manage account balance BalanceController
. 我创建一个控制器来管理帐户余额
BalanceController
。 It's supposed to use data from the Invoices and Expenses table. 应该使用“发票和费用”表中的数据。 So I added one action to the BalanceController called
account_balance
. 因此,我向BalanceController添加了一个名为
account_balance
。 But I need to add a month and year param to generate a balance report. 但是我需要添加月份和年份参数以生成余额报告。
This doesn't seem to work on routes.rb 这似乎在routes.rb上不起作用
get 'balance/account_balance/:month' => 'balance#account_balance/:month'
get 'balance/account_balance/:month' => 'balance#account_balance'
The string is just a controller/action combo. 该字符串只是一个控制器/动作组合。
Going to /balance/account_balance/march would then route to the account_balance
action of the balance
controller and params[:month]
would be set to 'march'. 然后转到/ balance / account_balance / march,将路由到
balance
控制器的account_balance
操作,并且params[:month]
将设置为'march'。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.