Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 轨道可以';无法找到子窗体的销毁方法_Ruby On Rails - Fatal编程技术网

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