I''m trying to create a search field using the form_tag helper. The problem is when I enter a search, the url_for returns an address such as host.com/search?term=foo. I want to use the format host.com/search/term. I have it set up in routes to recognize the format search/:term, but form_tag always uses the format host.com/search?term=foo. Does anybody know how to do this? Cheers! Ray -- 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-/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 -~----------~----~----~----~------~----~------~--~---
all I can think of is that order of routes matters, and there may be a conflict with the default \:controller\:action scheme. try moving it up the list, but be careful that it doesn''t break the rest of your routes. On 12/11/06, Raymond O''connor <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I''m trying to create a search field using the form_tag helper. The > problem is when I enter a search, the url_for returns an address such as > host.com/search?term=foo. I want to use the format > host.com/search/term. I have it set up in routes to recognize the > format search/:term, but form_tag always uses the format > host.com/search?term=foo. Does anybody know how to do this? > > Cheers! > Ray > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Mike Weber Web Developer UW-Eau Claire --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I have the route at the top of the file and it still doesn''t work. Here is the line from my routing file: map.connnect ''products/search/:term'', :conditions => { :method => :get }, :controller => ''products'', :action => ''search'' and here is the rhtml where I display the search bar: <% form_tag({:controller => ''products'', :action => ''search''}, {:method => ''get''}) do %> <%= text_field_tag :term, params[:term] %> <input type="submit" value ="search" /> <% end %> When I search using this bar, I always get addresses like this: http://localhost:3004/products/search?term=hello. Anything look wrong with the above? Thanks for the help! -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Well, besides connect being spelt with three n''s I don'' think that there is anything wrong with your code. And rails is behaving exactly as expected too. When the form is created, I believe that rails will generate html like this (it did when I looked at your code); <form action="/products/search" method="get"> <input id="term" name="term" type="text" value="fred" /> <input type="submit" value="search" /> </form> So, "term" is supposed to vary depending upon what the user keys in but then "term" is also supposed to appear into the html before the user types in anything. I don''t think that there is much change of that working. The URL generated from the form is fine. http://localhost:3004/products/search?term=something is correct. The routing is working. You can see this if add some code to the search.rthml view that displays the value of the params[:term]. Also a URL like http://localhost:3004/products/search/here-is-my-term works. params[:term] is set to "here-is-my-term" in the search method of the controller. When the user then keys in a value into the form and clicks the submit button, the URL becomes http://localhost:3004/products/search/here-is-my-term?term=<some user entered value> Maybe dropping the route and just letting the form do it''s thing is the simplest way forward? regards, Bruce. On 12/12/06, Raymond O''connor <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have the route at the top of the file and it still doesn''t work. Here > is the line from my routing file: > > map.connnect ''products/search/:term'', > :conditions => { :method => :get }, > :controller => ''products'', > :action => ''search'' > > and here is the rhtml where I display the search bar: > > <% form_tag({:controller => ''products'', :action => ''search''}, {:method > => ''get''}) do %> > <%= text_field_tag :term, params[:term] %> > <input type="submit" value ="search" /> > <% end %> > > > > When I search using this bar, I always get addresses like this: > http://localhost:3004/products/search?term=hello. Anything look wrong > with the above? Thanks for the help! > > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
I need 2 display the content of textbox in a html page to another -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Have a google for the term ''scraping a web page''. That''s what you''re trying to do, unless of course that "other" html page is on your server already. Walter On Dec 22, 2011, at 2:17 AM, Arunsunai S. wrote:> I need 2 display the content of textbox in a html page to another > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.