2012-12-20 2 views
1

저는 Ruby on Rails에 처음으로 익숙해졌으며 쉬운 문제인 것처럼 보였습니다. 그러나 내가 잘못했는지 파악할 수 없습니다. 내 홈페이지에는 단추가 있으며 버튼을 클릭하면 데이터베이스의 정보로 xml 파일을 생성합니다.Ruby on Rails의 라우팅 오류

버튼 코드 :

<%= button_to "Create Google File", :action => :create_google_file %> 

컨트롤러 코드 :

class ProductsController < ApplicationController 
    def new 
    end 

    def create_google_file  
     @products = Product.find(:all) 
     file = File.new('dir.xml','w') 
     doc = @products.to_xml 

     file.puts doc 
     file.close 
    end 
end 

내가지고있어 오류가

No route matches {:action=>"create_google_file", :controller=>"products"} 
+0

에있는 버튼을 변경? – tbraun89

+0

'GoogleMine :: Application.routes.draw 할 GET "새 제품 /" 자원 : 제품에 루트 '제품 # 새로운' end' –

+0

당신을 도움이 될 것입니다 안드레아스 Lyngstad 응답에서보세요. – tbraun89

답변

1

이 설정/routes.rb 파일이 추가입니다

match "/create_google_file" => "products#create_google_file", :as => :create_google_file 

그리고 제발 당신이 당신의`routes.rb` 파일이 보여줄 수있는이

<%= button_to "Create Google File", create_google_file_path %>