1
Railsアプリケーションのルーティングに問題があります。未初期化定数CustomersController - Rails
uninitialized constant CustomersController
これは私が従うことをしようとしているリンクです:私はnew_customer_pathへのリンクをたどるしようとすると、私はこのエラーを取得します。私のムービーコントローラの「新しい」ページにあります。
<div class="row">
<div class="col-xs-12">
<hr />
<%= link_to "Add Customer", new_customer_path, class: 'white' %>
</div>
</div>
カスタマー・コントローラー:
class CustomerController < ApplicationController
def new
@customer = Customer.new
end
def create
@customer = Customer.new(customer_params)
if @customer.save
redirect_to new_customer_path
end
end
private
def customer_params
params.require(:customer).permit(:fname, :lname, :telephone, :email)
end
end
ルート:
Rails.application.routes.draw do
resources :customers
resources :movies do
resources :rentals
end
root 'movies#new'
end
カスタマーモデル:
class Customer < ApplicationRecord
has_many :rentals
end
任意の考えここで "新しい" ページの関連部分があります/ tipsは非常に高く評価されるでしょう!
これは良いキャッチです!残念ながら、それはより広い問題を修正しませんでした。これで、代わりに「初期化されていない定数CustomersController」が表示される –
コントローラーの名前を変更しましたが、そのコントローラーの名前は変更しませんでしたか? –
それは問題でした。あなたがた両方に感謝します! –