Advertisement
Guest User

Untitled

a guest
Feb 13th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.12 KB | None | 0 0
  1.   after_action :create_notifier, only: %I[create]
  2.   after_action :destroy_notifier, only: %I[destroy]
  3.  
  4.   def destroy
  5.     # authorize Spaceship
  6.     @spaceship.destroy
  7.     respond_to do |format|
  8.       format.html do
  9.         if @spaceship.destroyed?
  10.           flash[:notice] = 'Удалено'
  11.         else
  12.           flash[:alert] = 'Ошибка удаления'
  13.         end
  14.       end
  15.       format.js
  16.     end
  17.     redirect_to spaceships_path
  18.   end
  19.  
  20.   private  
  21.  
  22.   def create_notifier
  23.     ActionCable.server.broadcast SpaceshipsChannel::TITLE,
  24.                                  partial: render_to_string(
  25.                                      partial: "spaceships/spaceship", object: @spaceship
  26.                                  )
  27.   end
  28.  
  29.   def destroy_notifier
  30.     ActionCable.server.broadcast SpaceshipsChannel::TITLE,
  31.                                  partial: render_to_string(
  32.                                      partial: "spaceships/spaceship", object: @spaceship
  33.                                  ),
  34.                                  action: destroy.to_s,
  35.                                  id: @expedition.id
  36.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement