简体   繁体   中英

Rails generate url from array with parameters

I wondered if there's some way to do this

polymorphic_path([@page, @image])

but like this

polymorphic_path([@page, :image_id => 1])

It's for the purposed of refactoring where I'd like to throw various params into the array and where they're null, they're ignored, but otherwise they generate the relevant nested url.

Thanks in advance.

polymorphic_path(:page_id => @page.id, :image_id => 1)

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