如果我有一个包含一个文本字段的表单,我可以以某种方式转到像
这样的网址/some/url/contents_of_form
如果用户在text_field中输入“google.com”并按“提交”时进行域名搜索,则会转到/domain/google.com
,然后路由调度google.com和............显示whois用户
答案 0 :(得分:2)
在您的routes.rb文件中输入
resource domain, :only => [] do
get search_form
get search
end
match 'domain/:location_name' => 'domains#whois'
在app / controllers / domains_controller.rb
中class DomainsController < ApplicationController
def search_form
#serve search form with text field. Text field has name="location"
end
def search
redirect_to "domain/#{params[:location]}"
end
def whois
@location = params[:location]
end
end
答案 1 :(得分:1)
您可以从javascript:http://www.ezineasp.net/post/Javascript-Window-Location-Href-URL.aspx
更改window.location.href