Class: UserMessagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/user_messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

post /user_messages



6
7
8
9
10
11
12
13
14
# File 'app/controllers/user_messages_controller.rb', line 6

def create
  @entity = UserMessage.new(creation_parameters)
  if @entity.save
    notify_receiver
    redirect_to dialog_my_messages_path(user_slug: @entity.receiver.slug)
  else
    render :new, status: :bad_request
  end
end

#destroyObject

delete /user_messages/:id



17
18
19
20
# File 'app/controllers/user_messages_controller.rb', line 17

def destroy
  other_user_slug = @entity.destroy_by_user(current_user)
  redirect_to dialog_my_messages_path(user_slug: other_user_slug)
end