简体   繁体   中英

How to change a route in rails 3?

Now I have address like domain/:board_id/:theme_id/ . But I want to create something like domain/:board_name/:theme_id . What shoud I do?

match ':board_name/:them_id' => 'some_controller#index'

Then you can use ActionView helpers:

link_to 'Some link', :board_name => 'some_name', :them_id => 12

You will have the link your_domain/some_name/12

In the controller you can get that parameters as:

params[:them_id]
params[:board_name]

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