Ruby on Rails Tuesday, March 29, 2011

Rails-3.0.5

I am writing a custom matcher in routes.rb. I wish to map a dynamic
segment to a nested params hash. I cannot seem to determine how to pass
the value of the dynamic segment to a nested hash.

The code that I have is:

get "(/:path)/:pars",
:action => :create,
:controller => :customs_shipment_pars_checks,
:ca_customs_manifest => { :ccdn => :pars }

This passes params[:ca_customs_manifest][:ccdn] == :pars # a symbol
and params[:pars] == "somevalue"

changing the last line to:

:ca_customs_manifest => { :ccdn => %(pars) }

This passes params[:ca_customs_manifest][:ccdn] == pars # a string
and params[:pars] == "somevalue"

What I wish to do is to pass the dynamically assigned value of :pars to
the nested hash. How is this done?

--
Posted via http://www.ruby-forum.com/.

--
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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment