破壊が成功した後、イベントリストの部分を更新する方法を見てください
_event_list.haml (更新用の部分)
%table.twelve#events
%thead
%tr
-#%th Game/Event
-#%th Result
-#%th Team
%th Opponent
-#%th Date
-#%th Time
%th Location
- if can? :update, @event
%th.span1 Manager
%tbody
- @events.each do |event|
%tr
-#%td= event_display(event.event)
-#%td= find_result(event)
-#%td= event.team.name
%td= link_to event.opponent.name, event
-#%td= check_date(event)
-#%td
= "#{event.datetime.to_s(:event_time)} - #{end_time(event)}"
%div{:style => 'font-size: .8em;color:#666; margin-top: 3px'}= "Arrived at #{arrive_time(event)}"
%td
- if event.location
= link_to event.location.name, event, :rel => 'tooltip-html', :title => 'View ' + event.location.name
- if can? :update, @event
%td
.btn-group
%button.btn.dropdown-toggle{"data-toggle" => "dropdown"}
%i.icon-pencil
Manage
%span.caret
%ul.dropdown-menu
%li= link_to "Edit #{event_display(event.event)}", edit_event_path(event)
%li= link_to "Delete #{event_display(event.event)}", event, :method => :delete, :remote => :true, :class => 'deleteRecord'
destroy.js.erb $("events").html("<%= escape_javascript(render(:partial => "events_list")) %>");
イベントコントローラー
def destroy
@event = Event.find(params[:id])
@event.destroy
respond_to do |format|
format.html { redirect_to(events_url,
:notice => "#{event_display_c(@event.event)} vs #{@event.opponent.name} was successfully deleted.") }
format.js
end
end