Reputation: 3
I am new to RoR, and I wonder how I can do a google search by using a field in view of my project, anyone know how I could do that?
I have in my application.html.haml the code :
%form#search
%input
How can i implement this?
Upvotes: 0
Views: 292
Reputation: 239342
Set the action
of your form to http://www.google.com/search
, the method
to get
, and name your input
field q
. Something like the following:
%form#search(action="http://www.google.com/search" method="get")
%input(type="text" name="q")
%input(type="submit")
The result will be the normal URL for google searches with the results displayed:
http://www.google.com/search?q=term1+term2
Upvotes: 1