Ruby on rails 轨道可以';无法找到子窗体的销毁方法
我有两门课,Ruby on rails 轨道可以';无法找到子窗体的销毁方法,ruby-on-rails,Ruby On Rails,我有两门课,Event和LivingGroupLivingGroup有很多活动,因此我为LivingGroup在我的_form.html.erb中添加了以下内容: <div id='event_children'> <% f.fields_for :events do |event_form| %> <%= render :partial => 'event', :locals => { :f => event_form } %>
Event
和LivingGroup
LivingGroup有很多活动,因此我为LivingGroup
在我的_form.html.erb中添加了以下内容:
<div id='event_children'>
<% f.fields_for :events do |event_form| %>
<%= render :partial => 'event', :locals => { :f => event_form } %>
<% end %>
</div>
<p>
<%= add_child_link 'Add Event', 'event', f %>
</p>
但是,我在rails中遇到以下错误:
NoMethodError in Living_groups#new
Showing app/views/living_groups/_event.html.erb where line #24 raised:
undefined method `_destroy' for #<Event:0x7f6da74b1a60>
Extracted source (around line #24):
21: </p>
22: <p>
23: <%= f.hidden_field :destroy, :class => 'delete' %>
24: <%= remove_child_link 'remove', f %>
25: </p>
26: </div>
Trace of template inclusion: app/views/living_groups/_form.html.erb, app/views/living_groups/new.html.erb
编辑:哎呀。希望这对其他人有所帮助。哎呀,在rails 2.3.5中删除了
NoMethodError in Living_groups#new
Showing app/views/living_groups/_event.html.erb where line #24 raised:
undefined method `_destroy' for #<Event:0x7f6da74b1a60>
Extracted source (around line #24):
21: </p>
22: <p>
23: <%= f.hidden_field :destroy, :class => 'delete' %>
24: <%= remove_child_link 'remove', f %>
25: </p>
26: </div>
Trace of template inclusion: app/views/living_groups/_form.html.erb, app/views/living_groups/new.html.erb
# DELETE /events/1
# DELETE /events/1.xml
def destroy
@event = Event.find(params[:id])
@event.destroy
respond_to do |format|
format.html { redirect_to(events_url) }
format.xml { head :ok }
end
end