为什么我现在无法编辑嵌套模型?
我收到以下错误:
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>
当我执行 rake paths | 时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"}
I get the following error:
undefined method `campaign_fax_path' for #<ActionView::Base:0xb6515200>
I have routes defined as follows:
map.resources campaigns, :has_many => :faxes
The error occurs here:
NoMethodError in Faxes#edit
Showing app/views/faxes/_form.html.erb where line #1 raised
I use a pretty basic form:
<% form_for [@campaign, @fax] do |f| %>
2 <%= f.error_messages %>
3 <p>
4 Campaign:
5 <%= link_to @campaign.name, campaign_path(@campaign) %>
6 </p>
When I do a rake routes | grep "campaign_fax*" I get the following:
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"}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您正在使用rails 2.3.X
在您的routes.rb 中尝试此操作
请参阅: Rails 指南的嵌套路由部分
I'm assuming that you are using rails 2.3.X
Try this in your routes.rb
See: The Nested Routes Section of the Rails Guides
显示 app/views/faxes/_form.html.erb 其中第 1 行引发的
部分可能有问题。你检查了吗?
Showing app/views/faxes/_form.html.erb where line #1 raised
Maybe there is something wrong in the partial. have you check it?