How to accept hash parameters in routes

Query:

I have a link like

<%= link_to "link_name", :controller => "some_controller", :action =>
"some_action", :id => "some_id", :first_param => {:second_param => "some
value"} %>

and in my routes.rb

map.connect '/some_name/:id' :controller => "some_controller", :action
=> "some_action"

Above code is giving me a URL like

http://localhost:3000/some_name/some_id

my requirement is to construct the URL as:

http://localhost:3000/some_name/some_id/value_inside_params[:first_param][:second_param]

Please help me out.

Thanks,

Saurabh

Answers


You can use route globbing:

map.connect '/some_name/:id/*other', :controller => 'some_controller',
            :action => 'some_action'

—this will make the additional parameters accessible within your action via params[:other].


Need Your Help

Problem with Windows XP scheduler calling C# app requiring passing of variable

c# windows-xp scheduled-tasks

I have a C#.net app I need to run off a computer. It has to be scheduled. I am using Windows XP Professional and the app is in C#.net. I have attempted to schedule the job, but I think my syntax...

CakePHP 2.0 - customize database error message

database cakephp error-handling cakephp-2.0

I have a CakePHP 2.0 application with a MySQL database. Two database tables are connected with a 1:n relation and a foreign key constraint.