Tuesday, July 17, 2012

[Rails] 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?

Thanks,

kingston.s

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate