Skip to content

Instantly share code, notes, and snippets.

@marcelloma
Created May 24, 2011 18:03

Revisions

  1. Marcello Milhomem Albuquerque created this gist May 24, 2011.
    30 changes: 30 additions & 0 deletions sections_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    class SectionsController < ApplicationController

    load_and_authorize_resource

    expose(:section)
    expose(:sections) { search.paginate(:page => params[:page]) }
    expose(:search) { Section.search(params[:search]) }

    def create
    if section.save
    redirect_to(sections_url, :notice => t(:create_success, :model => t_model(:section)))
    else
    render :action => "new"
    end
    end

    def update
    if section.update_attributes(params[:section])
    redirect_to(sections_url, :notice => t(:update_success, :model => t_model(:section)))
    else
    render :action => "edit"
    end
    end

    def destroy
    section.destroy
    redirect_to(sections_url, :notice => t(:delete_success, :model => t_model(:section)))
    end

    end