2011-08-16 4 views

답변

0

다음과 같이 구조화 된 양식은 무엇입니까? 예를 들어

:

그래서 경우 컨트롤러 액션에 :q라는 매개 변수에합니다 (routes.rb 파일에 작성 됨) search_path 노선 GET 요청을 시작하고 통과

= form_tag(search_path, :method => "get") do 
    = label_tag(:q, "Search for:") 
    = text_field_tag(:q) 
    = submit_tag("Search") 

match :search, :to => 'my_controller#search', :via => [:get] 

그런 다음 컨트롤러 교류 : 당신의 routes.rb 파일이 있었다 윤곽 MyController#search는 다음과 같이 보입니다

def search 
    # this is the parameter passed in from the form 
    query_string = params[:q] 

    # now do something with the parameter... 
end 
관련 문제