Rails 3.1 Optional Routes

Hi all,

I am using Rails 3.1 and Ruby 1.9.2

In my application i am using optional routes like below
match 'Gallery(/:gallery_id(/:image_id))(/page/:g_page)' => "wps/
gallery#show_gallery_page",:as => :gallery_page

in console i am trying to call the routes like below

include Rails.application.routes.url_helpers
=> Object
1.9.3dev :002 > gallery_page_path
=> "/Gallery"
1.9.3dev :003 > gallery_page_path(:gallery_id => 3)
=> "/Gallery/3"
1.9.3dev :004 > gallery_page_path(:image_id => 6)
=> "/Gallery?image_id=6"
1.9.3dev :005 >

if i pass gallery_id means it is giving expected result,but i pass
image_id means i am getting like "/Gallery?image_id=6",i except the
output to be "/Gallery/6" in controller i need to get image_id => 6..

Could any one please tell me how to use optional routes?



This question seems like a general Rails question; i.e. something particular to your application. In that case, please ask this question on rubyonrails-talk or Stack Overflow.

This list is reserved for questions and discussion about the core of Rails itself.