Skip to content

Instantly share code, notes, and snippets.

@axilaris
Created March 13, 2014 11:56
Show Gist options
  • Save axilaris/9527058 to your computer and use it in GitHub Desktop.
Save axilaris/9527058 to your computer and use it in GitHub Desktop.
class AnothersController < ApplicationController
before_action :set_another, only: [:show, :edit, :update, :destroy]
# GET /anothers
# GET /anothers.json
def index
@anothers = Another.all
end
# GET /anothers/1
# GET /anothers/1.json
def show
end
# GET /anothers/new
def new
@another = Another.new
end
# GET /anothers/1/edit
def edit
end
# POST /anothers
# POST /anothers.json
def create
@another = Another.new(another_params)
respond_to do |format|
if @another.save
format.html { redirect_to @another, notice: 'Another was successfully created.' }
format.json { render action: 'show', status: :created, location: @another }
else
format.html { render action: 'new' }
format.json { render json: @another.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /anothers/1
# PATCH/PUT /anothers/1.json
def update
respond_to do |format|
if @another.update(another_params)
format.html { redirect_to @another, notice: 'Another was successfully updated.' }
format.json { render action: 'show', status: :ok, location: @another }
else
format.html { render action: 'edit' }
format.json { render json: @another.errors, status: :unprocessable_entity }
end
end
end
# DELETE /anothers/1
# DELETE /anothers/1.json
def destroy
@another.destroy
respond_to do |format|
format.html { redirect_to anothers_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_another
@another = Another.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def another_params
params[:another]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment