Class: Administrate::Generators::DashboardGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Administrate::Generators::DashboardGenerator
- Defined in:
- lib/generators/administrate/dashboard/dashboard_generator.rb
Constant Summary collapse
- ATTRIBUTE_TYPE_MAPPING =
{ boolean: "Field::Boolean", date: "Field::DateTime", datetime: "Field::DateTime", enum: "Field::String", float: "Field::Number", integer: "Field::Number", time: "Field::Time", text: "Field::Text", string: "Field::String", }
- ATTRIBUTE_OPTIONS_MAPPING =
{ enum: { searchable: false }, float: { decimals: 2 }, }
- DEFAULT_FIELD_TYPE =
"Field::String.with_options(searchable: false)"
- COLLECTION_ATTRIBUTE_LIMIT =
4
- READ_ONLY_ATTRIBUTES =
%w[id created_at updated_at]
Instance Method Summary collapse
Instance Method Details
#create_dashboard_definition ⇒ Object
31 32 33 34 35 36 |
# File 'lib/generators/administrate/dashboard/dashboard_generator.rb', line 31 def create_dashboard_definition template( "dashboard.rb.erb", Rails.root.join("app/dashboards/#{file_name}_dashboard.rb"), ) end |
#create_resource_controller ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/generators/administrate/dashboard/dashboard_generator.rb', line 38 def create_resource_controller destination = Rails.root.join( "app/controllers/#{namespace}/#{file_name.pluralize}_controller.rb", ) template("controller.rb.erb", destination) end |