I am trying to create an application thats allows searching on an item number. There are multiple items in the DB with the same number (different vendors). My index page has a simple form that just accepts an item number in a form as: <% form_tag(all_item_search_path) do %> When I try to load this page, I get: all_item_search_url failed to generate from {:method=>:get, :action=>"search", :controller=>"public"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["search", :item_number] - are they all satisfied? My route.rb contains: map.all_item_search "/search/:item_number", :controller => "public", :action => "search", :method => :get and rake routes gives me the following: all_item_search /search/:item_number {:method=>:get, :action=>"search", :controller=>"public"} I can enter a url in the browser as such: http://localhost:3000/search/1234 I get the results of the search back. Also, would it be better to use /search?item=1234 # item numbers are alphanumeric and can have special characters The last part of the question is how will an xml request be specified. I know they are specified as /items.1.xml in a normal case. Thank you Don French --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Any help on this please! On Jan 10, 1:03 pm, dhf <dhf0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am trying to create an application thats allows searching on an item > number. There are multiple items in the DB with the same number > (different vendors). > > My index page has a simple form that just accepts an item number in a > form as: > <% form_tag(all_item_search_path) do %> > > When I try to load this page, I get: > all_item_search_url failed to generate from > {:method=>:get, :action=>"search", :controller=>"public"} - you may > have ambiguous routes, or you may need to supply additional parameters > for this route. content_url has the following required parameters: > ["search", :item_number] - are they all satisfied? > > My route.rb contains: > map.all_item_search "/search/:item_number", :controller => > "public", :action => "search", :method => :get > > and rake routes gives me the following: > all_item_search /search/:item_number > {:method=>:get, :action=>"search", :controller=>"public"} > > I can enter a url in the browser as such:http://localhost:3000/search/1234 > I get the results of the search back. > > Also, would it be better to use /search?item=1234 # item numbers are > alphanumeric and can have special characters > > The last part of the question is how will an xml request be specified. > I know they are specified as /items.1.xml in a normal case. > > Thank you > Don French--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
Hi Don, On Jan 11, 2008 10:03 AM, dhf <dhf0820-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am trying to create an application thats allows searching on an item > number. There are multiple items in the DB with the same number > (different vendors). > > My index page has a simple form that just accepts an item number in a > form as: > <% form_tag(all_item_search_path) do %> > > When I try to load this page, I get: > all_item_search_url failed to generate from > {:method=>:get, :action=>"search", :controller=>"public"} - you may > have ambiguous routes, or you may need to supply additional parameters > for this route. content_url has the following required parameters: > ["search", :item_number] - are they all satisfied?As the error suggests, you need an item_number parameter: form_tag all_item_search_path(item_number) do ... end> My route.rb contains: > map.all_item_search "/search/:item_number", :controller => > "public", :action => "search", :method => :get > > and rake routes gives me the following: > all_item_search /search/:item_number > {:method=>:get, :action=>"search", :controller=>"public"} > > I can enter a url in the browser as such: http://localhost:3000/search/1234 > I get the results of the search back. > > Also, would it be better to use /search?item=1234 # item numbers are > alphanumeric and can have special charactersRemove :item_number from the route: map.all_item_search "/search", :controller => "public", :action => "search", :method => :get And now: form_tag all_item_search_path(:item_number => item_number) do ... end> The last part of the question is how will an xml request be specified. > I know they are specified as /items.1.xml in a normal case.Add a formatted route: map.formatted_all_item_search "/items.:format", :controller => "public", :action => "search", :method => :get form_tag formatted_all_item_search_path(''xml'', :item_number => item_number) do ... end Having said all this, I''m wondering if a more RESTful architecture would be a better way to go--when you do things RESTfully, you get all this stuff for free. It sounds like you have a few resources like searches and items, but as I lack the bigger picture, that''s as far as I can really go here. Hope this helps anyway. Regards, George. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---