0

しばらく見ていない Rails プロジェクトに戻ります。これはおそらく、私には見えない非常に単純なものです。

よくある質問のために、アプリにほとんど静的なビューがあります。ルートをかき集めると、問題なく表示されます。

faq        /faq(.:format)     base_pages#faq

非常に単純な rspec テストをセットアップして、機能していることを確認しました。

describe "BasePages" do
    describe "FAQ" do
        before { visit faq_path }

        it { should have_selector('h1', text: "FAQ") }
    end
end

テストを実行すると、次のエラーが発生します。

  1) BasePages FAQ 
     Failure/Error: before { visit faq_path }
     ActionView::Template::Error:
       No route matches {:action=>"show", :controller=>"festivals", :id=>nil}
     # ./app/views/base_pages/faq.html.erb:130:in `_app_views_base_pages_faq_html_erb___446447898979674530_70112514729120'
     # ./spec/requests/base_pages_spec.rb:105:in `block (3 levels) in <top (required)>'

以下は私のconfig/routes.rbです:

Cif::Application.routes.draw do

  resources :posts

  match '/news', to: 'posts#index'

  get "payment/cancel"

  get "payment/success"

  post "payment/record"

  post "stripe_events/record"

  resources :submissions do
    resources :links, only: [:new, :create, :edit, :update, :destroy]
    resources :performers, only: [:new, :create, :edit, :update, :destroy]
    resources :charges, only: [:new, :create]
  end

  resources :festivals, only: [:index, :show]
  resources :submissions, only: :index
  resources :admin, only: :index
  resources :curator, only: :index

  devise_for :users

  namespace :admin do
    resources :users, only: [:index, :show, :edit, :update]
    resources :submissions do
      member do
        get 'notify'
        get 'format_for_wordpress'
      end
    end
    resources :festivals do
      resources :categories, except: :index
    end
  end

  namespace :curator do
    resources :submissions, only: [:index, :show] do
      resources :assessments, only: [:new, :edit, :create, :update]
    end
  end

  root to: 'base_pages#home'

  match '/about',   to: 'base_pages#about'
  match '/contact', to: 'base_pages#contact'
  match '/faq',     to: 'base_pages#faq'
  match '/ping',    to: 'base_pages#ping'
  match '/confirmed',    to: 'base_pages#confirmed'

end
4

1 に答える 1