Sha256: 177aab0c0de3015db91f4e710976a5e9138c91ccc448b21f5e0fa97ed6e2bb2c
Contents?: true
Size: 1.46 KB
Versions: 15
Compression:
Stored size: 1.46 KB
Contents
class Admin::ScaffoldController < Admin::BaseController respond_to :html, :js before_filter :prepend_resource_views_prefix before_filter :fetch_object def index @search = current_resource_class.search(params[:search]) set_collection @search.page(params[:page] || 1) end def new set_object current_resource_class.new end def edit end def create set_object current_resource_class.new(params[:"#{resource_name}"]) if current_resource.respond_to?("administrator=") current_resource.administrator ||= current_administrator end current_resource.save respond_with(current_resource) end def update current_resource.attributes = params[:"#{resource_name}"] current_resource.save respond_with(current_resource) end def destroy current_resource.destroy respond_with(current_resource) end protected def fetch_object if params[:id] set_object(current_resource_class.find(params[:id])) end end # helpers overrides def current_resource_class @current_resource_class ||= params[:_admin_resource_type].classify.constantize end private def prepend_resource_views_prefix lookup_context.prefixes.unshift "admin/#{collection_name}" end def set_object(value) instance_variable_set("@#{resource_name}", value) end def set_collection(value) instance_variable_set("@#{collection_name}", value) end end
Version data entries
15 entries across 15 versions & 1 rubygems