Skip to content

MagicController as Example

cclausen edited this page Jan 9, 2013 · 1 revision
# 
# Example Controller for Magic Rails methods and our helpers
# 
class MagicController < InheritedResources::Base

  respond_to :json, :xml
  has_pagination
  has_scope :search

  load_and_authorize_resource :except => [:index, :show]

  def index
    super do |format|
      format.html do
        @search = params[:search]
        @search = nil if @search.blank?
      end
    end
  end

  def create
    @version = build_resource.versions.first
    @version.user = current_user
    super
  end
  
end