Skip to content

Instantly share code, notes, and snippets.

@obliviusm
Created June 6, 2018 15:49
Show Gist options
  • Select an option

  • Save obliviusm/6155ceae569a4d7ccae8100afcbb663b to your computer and use it in GitHub Desktop.

Select an option

Save obliviusm/6155ceae569a4d7ccae8100afcbb663b to your computer and use it in GitHub Desktop.
# app/controllers/messages_controller.rb
class MessagesController < ApplicationController
respond_to :html, :json
def new
@message = Message.new
respond_modal_with @message
end
def create
@message = Message.create(message_params)
respond_modal_with @message, location: messages_path
end
private
def set_message
@message = Message.find(params[:id])
end
def message_params
params.require(:message).permit(:name, :body)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment