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.