1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actiontext/test/dummy/app/controllers/messages_controller.rb

59 lines
1.2 KiB
Ruby
Raw Normal View History

class MessagesController < ActionController::Base
2018-02-08 16:02:16 -05:00
before_action :set_message, only: [:show, :edit, :update, :destroy]
# GET /messages
def index
@messages = Message.all
end
# GET /messages/1
def show
end
# GET /messages/new
def new
@message = Message.new
end
# GET /messages/1/edit
def edit
end
# POST /messages
def create
@message = Message.new(message_params)
if @message.save
redirect_to @message, notice: 'Message was successfully created.'
else
render :new, status: :unprocessable_entity
2018-02-08 16:02:16 -05:00
end
end
# PATCH/PUT /messages/1
def update
if @message.update(message_params)
redirect_to @message, notice: 'Message was successfully updated.'
else
render :edit, status: :unprocessable_entity
2018-02-08 16:02:16 -05:00
end
end
# DELETE /messages/1
def destroy
@message.destroy
redirect_to messages_url, notice: 'Message was successfully destroyed.'
end
private
# Use callbacks to share common setup or constraints between actions.
def set_message
@message = Message.find(params[:id])
end
2020-06-09 13:41:51 -04:00
# Only allow a trusted parameter list through.
2018-02-08 16:02:16 -05:00
def message_params
params.require(:message).permit(:subject, :content)
end
end