Skip to content

Instantly share code, notes, and snippets.

@tonyc
Forked from marcelloma/sections_controller.rb
Created June 7, 2011 15:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyc/1012484 to your computer and use it in GitHub Desktop.
Save tonyc/1012484 to your computer and use it in GitHub Desktop.
decent_exposure + meta_search + cancan
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment