Class: ActiveAdmin::Cms::Recipe::Ingredient
- Inherits:
-
Object
- Object
- ActiveAdmin::Cms::Recipe::Ingredient
- Defined in:
- lib/active_admin/cms/recipe/ingredient.rb
Direct Known Subclasses
ActiveAdmin::Cms::Recipes::SectionHelper::SectionContainer::Ingredient
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#options ⇒ Object
Returns the value of attribute options.
-
#section ⇒ Object
Returns the value of attribute section.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #add_fields_to(formtastic_form) ⇒ Object
-
#content_key ⇒ Object
returns the key to use for storing content.
-
#initialize(id, content_type, opts = {}) ⇒ Ingredient
constructor
A new instance of Ingredient.
- #input_settings(opts = {}) ⇒ Object
Constructor Details
#initialize(id, content_type, opts = {}) ⇒ Ingredient
Returns a new instance of Ingredient.
9 10 11 12 13 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 9 def initialize(id, content_type, opts = {}) @id = id @content_type = content_type @options = opts end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 6 def content_type @content_type end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 6 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 6 def id @id end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 6 def @options end |
#section ⇒ Object
Returns the value of attribute section.
6 7 8 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 6 def section @section end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 6 def title @title end |
Instance Method Details
#add_fields_to(formtastic_form) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 15 def add_fields_to(formtastic_form) page = formtastic_form.object content = page.content_for content_key #debugger fields = formtastic_form.fields_for(content) do |i_form| i_form.inputs do i_form.input :text end end #debugger fields end |
#content_key ⇒ Object
returns the key to use for storing content
29 30 31 32 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 29 def content_key return "#{section.section_key}:#{id}" if section id end |
#input_settings(opts = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/active_admin/cms/recipe/ingredient.rb', line 34 def input_settings opts = {} opts[:prefix] = {:label => title, :input_html => {:name => "content[#{content_key}]", :id => content_key.to_s.gsub(':', '__')}} [:hint] ||= description if description [:hint] ||= content_type.description if !description and !content_type.description.blank? .merge! @options if @options #debugger [ content_type.input_field, .merge(content_type.input_opts) ] end |