意味のないものを何時間もデバッグしようとする
エラーは次のとおりです。
undefined method `proposals' for nil:NilClass
次のモデルに 2 つの一対多の関連付けがあります。
entrepreneur.rb
...
has_many :findentrepreneurs, :dependent => :destroy
...
finentrepreneur.rb
belongs_to :entrepreneur
has_many :proposals
提案.rb
belongs_to :findentrepreneur
以下を使用して、ネストされたルーティング モデルを作成しました。
resources :entrepreneurs do
resources :messages do
collection do
post :delete_selected
end
end
resources :findentrepreneurs do
resources :proposals
end
end
最後に、私の proposals_controller.rb 新しいアクション
def new
@proposal = @findentrepreneurs.proposals.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @proposal }
end
end
誰かが助けてくれることを願っています
ありがとうございました