Sha256: 8328223355f3ffe4eabe35266a2be78882033a23e631c06996074e0a36df019e

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

class AreasController < ApplicationController
  include Applicat::Mvc::Controller::Resource
  
  load_and_authorize_resource
  
  rescue_from ActiveRecord::RecordNotFound, with: :not_found
  
  respond_to :html, :js, :json
  
  def index
    @areas = Area.order(:name)
      
    respond_to do |format|
      format.html
      format.json { render json: @areas.tokens(params[:q]) }
    end
  end
  
  def show
    @area = Area.find(params[:id])
  end
  
  def new
    @area = Area.new
  end
  
  def create
    @area = Area.new(params[:area])
    
    if @area.save
      redirect_to @area, notice: t('general.form.successfully_created')
    else
      render :new
    end
  end
  
  def edit
    @area = Area.find(params[:id])
  end
  
  def update
    @area = Area.find(params[:id])
    
    if @area.update_attributes(params[:area])
      redirect_to @area, notice: t('general.form.successfully_updated')
    else
      render :edit
    end
  end

  def destroy
    @area = Area.find(params[:id])
    @area.destroy
    redirect_to areas_url, notice: t('general.form.destroyed')
  end
  
  def resource
    @area
  end
  
  private
  
  def not_found
    redirect_to areas_path, notice: t('areas.exceptions.not_found')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voluntary-0.1.0.rc1 app/controllers/areas_controller.rb
voluntary-0.0.3 app/controllers/areas_controller.rb
voluntary-0.0.2 app/controllers/areas_controller.rb
voluntary-0.0.1 app/controllers/areas_controller.rb