Class: Channels::MessagesController

Inherits:
Gaggle::ChannelsController
  • Object
show all
Defined in:
app/controllers/gaggle/channels/messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/gaggle/channels/messages_controller.rb', line 12

def create
  @message = @channel.messages.new(resource_params)
  if @message.save
    respond_to do |format|
      format.html { redirect_to @channel, notice: "Message sent." }
      format.json { render json: @message, status: :created, location: @message }
    end
  else
    respond_to do |format|
      format.html { render :new, notice: "Message was not sent." }
      format.json { render json: @message.errors, status: :unprocessable_entity }
    end
  end
end