Sha256: a20bce04ef8633ac2f68df131e81d709e60d9ae1a56f92d29fe2822a65cdd0bc
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
class MessagesController < ApplicationController before_action :set_message, only: [:show, :edit, :update, :destroy] before_action :protect_from_spam, only: [:create, :update] # 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 end end # PATCH/PUT /messages/1 def update if @message.update(message_params) redirect_to @message, notice: 'Message was successfully updated.' else render :edit 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 # Only allow a trusted parameter "white list" through. def message_params params.require(:message).permit(:name, :email, :telephone, :message) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
anti_spam-0.0.2 | test/dummy/app/controllers/messages_controller.rb |
anti_spam-0.0.1 | test/dummy/app/controllers/messages_controller.rb |