2012-04-19 131 views
0

我想命名空間我的網站到所有者/管理員,並擊中路由錯誤。當我嘗試創建一個新的財務報告(HTTP://本地主機:3000/EN /管理/ financial_reports /新) 我得到命名空間路由文件提供了路由錯誤

No route matches {:controller=>"financial_reports", :format=>nil} 

這裏是我的routes.rb(縮短)

scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do 
root :to => 'sites#index' 
get "logout" => "sessions#destroy", :as => "logout" 
get "login" => "sessions#new", as: "login" 
namespace :admin do 
    root :to => "base#index" 
    resources :financial_reports do 
     collection do 
     get :monthly 
     get :yearly 
     end 
    end 
    end 
namespace :owner do 
    root :to => "base#index" 
    end 
match "*path", to: "sites#not_found" # handles /en/fake/path/whatever 
end 
root to: redirect("/#{I18n.default_locale}") # handles/
match '*path', to: redirect("/#{I18n.default_locale}/%{path}") 
end 

這是我的控制器 應用程序/控制器/管理/ financial_reports_controller.rb

class Admin::FinancialReportsController < BaseController 

DEF指數 @financial_reports = FinancialReport.al升 端

DEF新 @financial_report = FinancialReport.new 端

DEF創建 @financial_report = FinancialReport.new(PARAMS [:financial_report]) 如果@ financial_report.save 閃光[:聲明] =「財務報告上傳成功」 redirect_to的root_url 其他 閃光燈[:警報] = 呈現「指數」 結束 結束 DEF「未成功上傳的財務報告」每年 @financial_reports = FinancialReport.yearly 結束 DEF月 @financial_reports = FinancialReport.monthly 結束 結束

和我的觀點

應用程序/視圖/管理/ financial_reports/new.html.erb

<%= form_for(@financial_report) do |f| %> 
<p> 
    <%= f.label(:report_type) %> <br> 
    <%= f.radio_button :report_type, "Monthly" %> Monthly | 
    <%= f.radio_button :report_type, "Yearly" %> Yearly 
</p> 
<p> 
    <%= f.file_field :file %> 
</p> 
<p> 
    <%= f.submit "Upload Monthly Record" %> 
</p> 
<% end %> 

任何想法,爲什麼我得到這個錯誤?由於

回答