Renato Durão
Renato Durão

Reputation: 3

Google Search with RoR, how make it works?

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

Answers (1)

user229044
user229044

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

Related Questions