Class: Transit::Admin::DSL
- Inherits:
-
Object
- Object
- Transit::Admin::DSL
- Defined in:
- lib/transit/admin.rb
Instance Attribute Summary collapse
-
#column_hash ⇒ Object
Returns the value of attribute column_hash.
-
#columns(*cols) ⇒ Object
Specify the columns to be displayed in the admin.
-
#fields(field_hash = {}) ⇒ Object
Specify the form fields used for each attribute.
Instance Method Summary collapse
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
Constructor Details
#initialize ⇒ DSL
Returns a new instance of DSL.
72 73 74 75 76 77 78 79 80 |
# File 'lib/transit/admin.rb', line 72 def initialize @fields = ActiveSupport::HashWithIndifferentAccess.new({ title: :text_field, teaser: :text_area, post_date: { date_select: { order: [:month, :day, :year], use_short_month: true } }, image: :file_field, photo: :file_field }) end |
Instance Attribute Details
#column_hash ⇒ Object
Returns the value of attribute column_hash.
26 27 28 |
# File 'lib/transit/admin.rb', line 26 def column_hash @column_hash end |
#columns(*cols) ⇒ Object
Specify the columns to be displayed in the admin. At minimum the name of a method is required. For additional options, use hash syntax.
the proc will be passed a reference to the current object.
config.columns :title, post_date: lambda{ |obj| obj.created_at.to_formatted_s }
44 45 46 |
# File 'lib/transit/admin.rb', line 44 def columns @columns end |
#fields(field_hash = {}) ⇒ Object
Specify the form fields used for each attribute. When inheriting posts or pages defaults are already pre-defined and normally only need to be overridden.
67 68 69 |
# File 'lib/transit/admin.rb', line 67 def fields @fields end |