简体   繁体   中英

rails rest routes with multiple params

I use Refinery CMS blog module to create a simple blog, now I try to customize archive section, I want to add one more param for archive link, default route for archive looks like:

blog_archive_posts GET     /blog/archive/:year(/:month)(.:format)

now my question is how can I call this in rails and how can I provide the params for blog_archive_posts_path ?

Try

<%= link_to "archive for #{year}/#{month}", 
            blog_archive_posts_path(year: @year, month: @month) %>

where @year and @month are defined in your controller appropriately

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