Sha256: 5f8dff93b3c8272b716ca362366dcb4bd2f8a989fced84b302f2abc553226e09
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
require "rails/generators/named_base" module Administrate module Generators class DashboardGenerator < Rails::Generators::NamedBase source_root File.expand_path("../templates", __FILE__) def create_dashboard_definition template "dashboard.rb.erb", "app/dashboards/#{file_name}_dashboard.rb" end def create_resource_controller template( "controller.rb.erb", "app/controllers/admin/#{file_name.pluralize}_controller.rb" ) end private def attributes klass.attribute_names + klass.reflections.keys end def field_type(attribute) klass.type_for_attribute(attribute).type || association_type(attribute) end def association_type(attribute) reflection = klass.reflections[attribute.to_s] if reflection.collection? :has_many else :belongs_to end end def klass @klass ||= Object.const_get(class_name) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems