Sha256: 2fc760a76f468c792f7ec837e51a3f1f81135daa8e9e197c11471ee79dab5749

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 Bytes

Contents

require 'inherited_resources'
module Admin
  class ResourcesController < AdminController

    inherit_resources    

    helper_method :list_fields
    def list_fields
      resource_class.column_names
    end
    
    helper_method :show_fields
    def show_fields
      (resource_class.column_names-["id","created_by","updated_by","created_at","updated_at"])
    end

    helper_method :search_fields
    def search_fields
      []
    end


    def create
      create! { collection_path }
    end
    def update
      update! { collection_path }
    end

    

    protected

      def collection
        @search = end_of_association_chain.search(params[:q])
        unless params[:all_pages]
          get_collection_ivar || set_collection_ivar(@search.result.paginate(:page => params[:page], :per_page => per_page))
        else
          get_collection_ivar || set_collection_ivar(@search.result)
        end
      end
     
      def per_page
        10
      end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unknown_admin-0.1.3 app/controllers/admin/resources_controller.rb
unknown_admin-0.1.2 app/controllers/admin/resources_controller.rb