使用RoR进行Google搜索,如何使其有效?

时间:2011-11-04 17:53:25

标签: ruby-on-rails ruby google-search google-search-api

我是RoR的新手,我想知道如何通过使用我的项目中的字段进行谷歌搜索,任何人都知道我该怎么做?

我在application.html.haml中有代码:

 %form#search
  %input

我该如何实现?

1 个答案:

答案 0 :(得分:1)

将表单的action设置为http://www.google.com/search,将method设置为get,并将input字段q命名为。如下所示:

%form#search(action="http://www.google.com/search" method="get")
  %input(type="text" name="q")
  %input(type="submit")

结果将是显示结果的Google搜索的常规网址:

http://www.google.com/search?q=term1+term2