Sha256: 6ae84a50a676a7b90eb6a401418e8bf5ad94aadb72411bcfe4f8f3ffb137725f
Contents?: true
Size: 1.44 KB
Versions: 33
Compression:
Stored size: 1.44 KB
Contents
class Admin::ScaffoldController < Admin::BaseController respond_to :html, :js before_filter :prepend_resource_views_prefix 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?(:author) current_resource.author ||= current_user 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 # overrides checkin default 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
33 entries across 33 versions & 1 rubygems