1

I need a backend for administration, I tried RailsAdmin and ActiveAdmin, but the limited level of customization and found the gem admin_interface which gave me the options I wanted.

This is the structure of my project

├── app
│   ├── assets
│   ├── controllers
│   │   ├── admin
│   │   │   ├── locations_controller.rb
│   │   ├── application_controller.rb
│   │   ├── locations_controller.rb
│   ├── models
│   │   ├── location.rb

class LocationsController < InheritedResources::Base
  respond_to :html, :json
  def index
    @locations = Location.all
    @json = Location.all.to_gmaps4rails
  end
end

class Admin::LocationsController < Admin::ResourceController  
  # See admin/resource_controller.rb for more info..
end

class Admin::ResourceController < Admin::BaseController

  inherit_resources # gem
  defaults :route_prefix => 'admin'

  # inherited_resources options
  # nested_belongs_to :user, :optional => true

  def destroy_all
    destroyed_resources = resource_class.destroy_all(:id => params[:ids])
    flash[:notice] = "#{destroyed_resources.size} objects destroyed."
    redirect_to :back
  end

protected

  # Overwrites inherited_resources gem version.
  # Use meta_search and kaminari gem to load collection
  def collection
    @search ||= end_of_association_chain.search(params[:q])
    get_collection_ivar || begin
      c = @search.result.page(params[:page]).per(params[:per])
      set_collection_ivar(c.respond_to?(:scoped) ? c.scoped : c)
    end
  end
end

As I can do to make admin>application_controller.rb inherits from application_controller.rb. I want @json = Lugar.all.to_gmaps4rails This also available for the admin controller?.

Thanks in advance.

  • Please make sure to write what problem you are facing ? – Arpit Vaishnav Mar 14 '12 at 12:20
  • Not how to make my backend-controller inherits from the controller, I know I set the gem [inherited_resources][https://github.com/josevalim/inherited_resources] not know how or where? – Benito Anagua Mar 14 '12 at 12:38
  • I guess you could create a class in between like: **class Admin::GeoController < Admin::BaseController** # add your stuff **end** Make others inherit from this class. (Thanks Joost Hietbrink) – Benito Anagua Apr 06 '12 at 13:43

0 Answers0