Sha256: 4a1b5d581e6ccf42cd44528beb27d2b3df962977c0339dae648fb0274e31d43e
Contents?: true
Size: 1.49 KB
Versions: 3
Compression:
Stored size: 1.49 KB
Contents
module Trestle class Admin extend ActiveSupport::Autoload autoload :Builder autoload :Controller class << self attr_accessor :menu attr_accessor :table attr_accessor :form attr_accessor :additional_routes attr_writer :options def options @options ||= {} end def breadcrumbs Breadcrumb::Trail.new(Array(Trestle.config.root_breadcrumbs) + [breadcrumb]) end def breadcrumb Breadcrumb.new(admin_name.titleize.pluralize, path) end def admin_name name.underscore.sub(/_admin$/, '') end def route_name "#{admin_name.tr('/', '_')}_admin" end def controller_path "admin/#{name.underscore.sub(/_admin$/, '')}" end def controller_namespace "#{name.underscore}/admin" end def path(action=:index, options={}) Engine.routes.url_for(options.merge(controller: controller_namespace, action: action, only_path: true)) end def routes admin = self Proc.new do scope controller: admin.controller_namespace, path: admin.options[:path] || admin.admin_name do get "", action: "index", as: admin.route_name instance_exec(&admin.additional_routes) if admin.additional_routes end end end def railtie_routes_url_helpers(include_path_helpers=true) Trestle.railtie_routes_url_helpers(include_path_helpers) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trestle-0.8.3 | lib/trestle/admin.rb |
trestle-0.8.2 | lib/trestle/admin.rb |
trestle-0.8.0 | lib/trestle/admin.rb |