我正在使用rails3。
在嵌套路由中加载新操作时,出现 NoMethod 错误。
#<#:0x0000000a067ef8> 的未定义方法“community_community_topics_path”
我怎样才能解决这个问题??
_form.html.erb
<%= form_for ([@community, @community_topic]), :html => { :class => 'form-horizontal' } do |f| %>
<div class="control-group">
<%= f.label :title, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :title, :class => 'text_field' %>
</div>
</div>
<div class="control-group">
<%= f.label :body, :class => 'control-label' %>
<div class="controls">
<%= f.text_area :body, :class => 'text_area' %>
</div>
</div>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
community_topics_path, :class => 'btn' %>
</div>
<% end %>
路线.rb
resources :communities, :path => "shop", do
resources :community_topics, :path => "topic", :as => :'topic'
end
耙路线 | grep community_topics
community_topic_index GET /shop/:community_id/topic(.:format) community_topics#index
POST /shop/:community_id/topic(.:format) community_topics#create
new_community_topic GET /shop/:community_id/topic/new(.:format) community_topics#new
edit_community_topic GET /shop/:community_id/topic/:id/edit(.:format) community_topics#edit
community_topic GET /shop/:community_id/topic/:id(.:format) community_topics#show
PUT /shop/:community_id/topic/:id(.:format) community_topics#update
DELETE /shop/:community_id/topic/:id(.:format) community_topics#destroy