Class: ActiveAdmin::Generators::Boilerplate
- Inherits:
-
Object
- Object
- ActiveAdmin::Generators::Boilerplate
- Defined in:
- lib/active_admin/generators/boilerplate.rb
Instance Method Summary collapse
- #assignable_attributes ⇒ Object
- #attributes ⇒ Object
- #column(name) ⇒ Object
- #columns ⇒ Object
- #filter(name) ⇒ Object
- #filters ⇒ Object
- #form_input(name) ⇒ Object
- #form_inputs ⇒ Object
-
#initialize(class_name) ⇒ Boilerplate
constructor
A new instance of Boilerplate.
- #permit_params ⇒ Object
- #row(name) ⇒ Object
- #rows ⇒ Object
Constructor Details
#initialize(class_name) ⇒ Boilerplate
Returns a new instance of Boilerplate.
5 6 7 |
# File 'lib/active_admin/generators/boilerplate.rb', line 5 def initialize(class_name) @class_name = class_name end |
Instance Method Details
#assignable_attributes ⇒ Object
13 14 15 |
# File 'lib/active_admin/generators/boilerplate.rb', line 13 def assignable_attributes attributes - %w(id created_at updated_at) end |
#attributes ⇒ Object
9 10 11 |
# File 'lib/active_admin/generators/boilerplate.rb', line 9 def attributes @class_name.constantize.new.attributes.keys end |
#column(name) ⇒ Object
33 34 35 |
# File 'lib/active_admin/generators/boilerplate.rb', line 33 def column(name) "# column :#{name.gsub(/_id$/, '')}" end |
#columns ⇒ Object
29 30 31 |
# File 'lib/active_admin/generators/boilerplate.rb', line 29 def columns attributes.map { |a| column(a) }.join("\n ") end |
#filter(name) ⇒ Object
41 42 43 |
# File 'lib/active_admin/generators/boilerplate.rb', line 41 def filter(name) "# filter :#{name.gsub(/_id$/, '')}" end |
#filters ⇒ Object
37 38 39 |
# File 'lib/active_admin/generators/boilerplate.rb', line 37 def filters attributes.map { |a| filter(a) }.join("\n ") end |
#form_input(name) ⇒ Object
49 50 51 |
# File 'lib/active_admin/generators/boilerplate.rb', line 49 def form_input(name) "# f.input :#{name.gsub(/_id$/, '')}" end |
#form_inputs ⇒ Object
45 46 47 |
# File 'lib/active_admin/generators/boilerplate.rb', line 45 def form_inputs assignable_attributes.map { |a| form_input(a) }.join("\n ") end |
#permit_params ⇒ Object
17 18 19 |
# File 'lib/active_admin/generators/boilerplate.rb', line 17 def permit_params assignable_attributes.map { |a| a.to_sym.inspect }.join(", ") end |
#row(name) ⇒ Object
25 26 27 |
# File 'lib/active_admin/generators/boilerplate.rb', line 25 def row(name) "# row :#{name.gsub(/_id$/, '')}" end |
#rows ⇒ Object
21 22 23 |
# File 'lib/active_admin/generators/boilerplate.rb', line 21 def rows attributes.map { |a| row(a) }.join("\n ") end |