0
嘗試調試東西小時未作出任何意義NoMethod錯誤 - 一對多關聯
的錯誤是:
undefined method `proposals' for nil:NilClass
我有兩個一個-to-many關聯以下型號:
entrepreneur.rb
...
has_many :findentrepreneurs, :dependent => :destroy
...
finentrepreneur.rb
belongs_to :entrepreneur
has_many :proposals
proposal.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
希望有人能幫助
Thankyou
你在哪裏設置@findentrepreneurs? – 2013-04-05 19:27:43