2011-04-07 49 views
2

我已經編寫了一個基本的Rails 3應用程序,該應用程序在特定的URL上顯示錶單和上載表單。昨天一切正常,但現在我遇到了幾個需要修復的問題。我會盡我所能地盡力描述每個問題。我把它們結合起來的原因是因爲我覺得它們都是相關的,並且阻止我完成我的任務。對應用程序請求的參數錯誤

1.不能運行在開發模式 應用對於一些未知的原因,我不能在發展模式下運行的應用程序。目前我使用開發環境中的設置覆蓋了環境中的production.rb文件,以實現實際的堆棧跟蹤。

我已將RailsEnv生產設置添加到apache2中的VirtualHost設置,但似乎沒有區別。設置ENV變量也不生產。

2.在所有引發ArgumentError呼籲 無論叫我似乎做,在此錯誤消息的結果。日誌文件告訴我下面的:

開始在 週四四月GET 「/」 爲192.168.33.82 07○時54分48秒-0700 2011

引發ArgumentError(錯號碼的 參數(1 0 )):

渲染 /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms的)渲染 /USR /lib/ruby/gems/1.8/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb渲染救援內 /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb (4.1ms)/佈局(8.4ms)

這對我來說毫無意義。我不知道發生了什麼問題。我現在只有一個控制器,它看起來像這樣:

class SearchEngineController < ApplicationController 
    def upload 
    end 

    def search 
    @rows = nil 
    end 

    # This function will receive the query string from the search form and perform a search on the 
    # F.I.S.E index to find any matching results 
    def query 
    index = Ferret::Index::Index.new :path => "/public/F.I.S.E", :default_field => 'content' 
    @rows = Array.New 
    index.search_each "content|title:#{params[:query]}" do |id,score, title| 
     @rows << {:id => id, :score => score, :title => title} 
    end 

    render :search 
    end 

    # This function will receive the file uploaded by the user and process it into the 
    # F.I.S.E for searching on keywords and synonims 
    def process 
    index = Ferret::Index::Index.new :path => "public/F.I.S.E", :default_field => 'content' 
    file = File.open params[:file], "r" 
    xml = REXML::Document.new file 
    filename = params[:file] 
    title = xml.root.elements['//body/title/text()'] 
    content = xml.root.elements['normalize-space(//body)'] 
    index << { :filename => filename, :title => title, :content => content} 
    file.close 
    FileUtils.rm file 
    end 
end 

我的應用程序的路由具有以下設置:再次,這是所有非常基本的,也許可以做得更好。

Roularta::Application.routes.draw do 
    # define all the url paths we support 
    match '/upload' => 'search_engine#upload', :via => :get 
    match '/process' => 'search_engine#process', :via => :post 

    # redirect the root of the application to the search page 
    root :to => 'search_engine#search' 

    # redirect all incoming requests to the query view of the search engine 
    match '/:controller(/:action(/:id))' => 'search_engine#search' 

end 

如果任何人都可以發現有什麼問題以及爲什麼此應用程序失敗,請告訴我。如果需要,我可以編輯這個awnser,幷包含解決此問題可能需要的其他文件。

編輯 我已經成功地通過重命名的控制器上的一個功能進一步得到。我將搜索重新命名爲create,現在我正在取回HAML錯誤。也許我使用了關鍵字...?

回答

0

活泉,終於找到了解決方案....

好像我用關鍵字來定義我的動作,和Rails不喜歡這個。這解決了問題2。

1期得到了通過添加Rails.env = '發展'到environment.rb文件中解決

相關問題