Friday, 15 June 2012

ruby - Rails Routes Evaluating Incorrectly -



ruby - Rails Routes Evaluating Incorrectly -

i'm using rails 2.3.18 , ruby 1.8.7

i have in view:

link_to 'download file', {:controller => 'inventory_data', :action => 'download_exported_inventory_items', :reference_id => 'somehashvalue'}

this outputs next link:

<a href="/vendors/inventory/download_exported_inventory_items?reference_id=somehashvalue">download file</a>

i have route specified in routes.rb

map.resources :inventory_data, :path_prefix => "vendors" |vendor| map.download_exported_inventory_items 'vendors/inventory/download_exported_inventory_items', :controller => :inventory_data, :action => "download_exported_inventory_items" end

when click on link, error caused beingness routed different controller action (specifically 'inventory_item'). looked rails route debugging , found way check controller action url maps to. set in console:

r = actioncontroller::routing::routes r.recognize_path "/vendors/inventory/download_exported_inventory_items"

which returned following:

=> {:controller=>"inventory_data", :id=>"download_exported_inventory_items", :action=>"inventory_item"}

any thoughts on how routes mixed this, or can debug problem further?

thanks in advance.

had before route matching because of way params[:id] set.

map.inventory_item 'vendors/inventory/:id', :controller => :inventory_data, :action => "inventory_item"

where

params[:id] = "download_exported_inventory_items"

ruby-on-rails ruby debugging routing

No comments:

Post a Comment