Method: ManageableContent::Controllers::Dsl::ClassMethods#manageable_content_for

Defined in:
lib/manageable_content/controllers/dsl.rb

#manageable_content_for(*keys) ⇒ Object

Configures the manageable contents for a Controller. For example, if the Controller will have a ‘body’ and a ‘side’ contents, the following should be set:

manageable_content_for :body, :side

This will also inherit manageable contents from superclasses. For example, if all your Controllers will have a ‘title’ content, you can add the following to ApplicationController, and all Controllers which inherit from it will have it too:

manageable_content_for :title

You can also set a content type for the given keys. By default they are :text content types. Available types are :text for long contents and :string for short contents.

manageable_content_for :title, :type => :string


67
68
69
70
71
72
73
74
# File 'lib/manageable_content/controllers/dsl.rb', line 67

def manageable_content_for(*keys)
  options = keys.last.is_a?(Hash) ? keys.pop : {}
  type    = options[:type] || :text

  if keys.present?
    self.manageable_content_keys = (self.manageable_content_keys.merge(keys_for_type(type, keys)))
  end
end