LoginSignup
0
0

More than 1 year has passed since last update.

ネスト外のresources

Posted at

スクリーンショット 2021-06-28 13.17.53.png

<修正前>

routes.rb
constraints host: config[:admin][:host] do
    namespace :admin, path: config[:admin][:path] do
      root "top#index"
      get "login" => "sessions#new", as: :login
      resource :session,only:[:create,:destroy]
      resources :staff_members do
        resources :staff_events, only: [ :index ]
      end

    end
  end

:admin_staff_eventsのprefixが生成されていないことを疑いました。モデル等を調べても問題なさそう。
ルーティングにおいてネストされたresources以外にも:staff_eventsが必要だと判明。

<修正後>

routes.rb
 constraints host: config[:admin][:host] do
    namespace :admin, path: config[:admin][:path] do
      root "top#index"
      get "login" => "sessions#new", as: :login
      resource :session,only:[:create,:destroy]
      resources :staff_members do
        resources :staff_events, only: [ :index ]
      end
      resources :staff_events, only: [ :index]    #<=ここを追記
    end
  end

無事に表示されました。

スクリーンショット 2021-06-28 13.29.04.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0