Routing?

Hello RoR Developers

I want to create parameter in routes.rb which is wanted to be used in
javascript code in view page. there is select object in my view page and
this parameter will get value from select object however that my select
object is not in form.
how can I create parameter in routes.rb and equals to option value.

thank you very much for any commend.

You can not do that because map.connect is formed like below:

map.connect ‘:any/:thing’,
:controller => “report”,
:action => “access”
:filter => :any
:thing => ‘any option’

~~~~~~~~~~~~~~
Reinhart Ariando
YM:Booking2Heaven
WEB: teapoci.blogspot.com
~
~~~~~~~~~~~~~

You can not do that because map.connect is formed like below:

map.connect ‘:any/:thing’,
:controller => “report”,
:action => “access”
:filter => :any
:thing => ‘any option’

do you have any idea how to do it?
I have a sample code of my friend but I didnt understand it well
%w( optimize report sheet ).each do |controller|
map.connect
“:enterprise_code/:m_hierarchy_id/:t_project_id/#{controller}/:action/:id”,
:controller => “project/#{controller}”,
:requirements => { :m_hierarchy_id => /\d+/, :t_project_id =>
/\d+/ }
end

in routes.rb

Actually I could nt understand the logic of parameters in routes.
my question was quite silly I think.

thank you very much for your commend again.

%w( optimize report sheet ).each do |controller|
map.connect
“:enterprise_code/:m_hierarchy_id/:t_project_id/#{controller}/:action/:id”,
:controller => “project/#{controller}”,
:requirements => { :m_hierarchy_id => /\d+/, :t_project_id =>
/\d+/ }
end

in routes.rb

if i read this script, it will work.

Let me explain your friend script mean off.

There will be 3 controllers name, you will run, optimize, report, sheet.

%w( optimize report sheet ).each do |controller|
map.connect
“:enterprise_code/:m_hierarchy_id/:t_project_id/#{controller}/:action/:id”

example your enterprise_code params in /project/optimize is ‘Voo_doo’,
and :t_project_id is ‘1’,:m_hierarchy_id is ‘2’, :action is ‘testing’,
:id is ‘5’

your url will be http://localhost:3000/voo_doo/02/01/optimize/testing/5


:requirements => {:name => /reg_exp/…}

specifies that the given components, if present in the URL, must each
match the specified ‘regular expressions’ in order for the map as a
whole to match. In other words, if any component does not match this map
will not be used.


:action is where your def method in your controller you want to use

Manual:
http://manuals.rubyonrails.com/read/chapter/65
http://api.rubyonrails.org/classes/ActionController/Routing.html

Nice to help you

~~~~~~~~~~~~~~
Reinhart Ariando
YM:Booking2Heaven
WEB: teapoci.blogspot.com
~
~~~~~~~~~~~~~

1 Manual left:

thank you again and again