2012-04-19 123 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 %> 

任何想法,为什么我得到这个错误?由于

回答