2010-12-18 15 views
0

私は次のエラーを取得する:なぜネストされたモデルを編集できないのですか?

undefined method `campaign_fax_path' for #<ActionView::Base:0xb6515200> 

私は次のように定義されたルートを持っている:

map.resources campaigns, :has_many => :faxes 

エラーがここに発生します。

NoMethodError in Faxes#edit 

Showing app/views/faxes/_form.html.erb where line #1 raised 

私はかなり基本的な形式を使用します。

<% form_for [@campaign, @fax] do |f| %> 
    2 <%= f.error_messages %> 
    3 <p> 
    4  Campaign: 
    5  <%= link_to @campaign.name, campaign_path(@campaign) %> 
    6 </p> 

私はレーキルートをするとき|私は、次の取得のgrep "* campaign_fax":

  campaign_faxes GET /campaigns/:campaign_id/faxes(.:format)    {:action=>"index", :controller=>"faxes"} 
     new_campaign_fax GET /campaigns/:campaign_id/faxes/new(.:format)   {:action=>"new", :controller=>"faxes"} 
+0

をご覧ください 'campaign_faxis' 「レーキルート」のどこにいても?はい、それは「ファックス」と「私」です。 – zetetic

答えて

1

私はあなたがあなたのroutes.rbをでこれを試してみてください2.3.x以降に

map.resources campaigns do |campaigns| 
    campaigns.resources :faxes 
end 

参照を

をレールを使用していると仮定しています:Nested Routes Section of the Rails Guides

+0

私はそれを修正しましたが、ガイドを読んで、それが何だったのか思い出すことはできません。 – Angela

0

表示アプリ/ビュー/ファックス/ _form.html.erbライン#1は

を上げたところたぶん部分的に間違った何かがあります。あなたはそれをチェックしていますか?

map.resources campaigns, :has_many => :faxes **is that correct? I don't think so... maybe is: 

map.resources campaign, :has_many => :faxes or 

map.resources campaign, :has_many => :faxes 

map.resources fax, :has_many => :campaigns 
関連する問題