简体   繁体   中英

Rails 3. How to setup a controller with custom params?

I create a controller to manage account balance BalanceController . It's supposed to use data from the Invoices and Expenses table. So I added one action to the BalanceController called 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM