Class: ActiveAdmin::Cms::Content
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveAdmin::Cms::Content
- Extended by:
- ActsAsMarkup::ActiveRecordExtension::ClassMethods
- Includes:
- ActionView::Helpers, Haml::Helpers
- Defined in:
- lib/active_admin/cms/content.rb
Instance Method Summary collapse
-
#content_type ⇒ Object
process_in_background :image process_in_background :file.
- #content_type=(type) ⇒ Object
- #content_type_class ⇒ Object
- #image_uploader ⇒ Object
- #set_content(value) ⇒ Object
- #to_html(options = {}) ⇒ Object
Instance Method Details
#content_type ⇒ Object
process_in_background :image process_in_background :file
26 27 28 |
# File 'lib/active_admin/cms/content.rb', line 26 def content_type content_type_class.constantize if content_type_class end |
#content_type=(type) ⇒ Object
34 35 36 |
# File 'lib/active_admin/cms/content.rb', line 34 def content_type=(type) update_attribute :content_type_class, type.to_s end |
#content_type_class ⇒ Object
30 31 32 |
# File 'lib/active_admin/cms/content.rb', line 30 def content_type_class super || 'ActiveAdmin::Cms::ContentTypes::String' end |
#image_uploader ⇒ Object
38 39 40 |
# File 'lib/active_admin/cms/content.rb', line 38 def image_uploader content_type.image_uploader end |
#set_content(value) ⇒ Object
42 43 44 |
# File 'lib/active_admin/cms/content.rb', line 42 def set_content(value) self.send("#{self.content_type.input_field}=", value) end |
#to_html(options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/active_admin/cms/content.rb', line 46 def to_html( = {}) #debugger html = '' if content_type.text_allowed? if content_type.markdown_allowed? html += text.to_html else html += text.to_s end end if content_type.image_allowed? if image = [:tag] ||= {} [:src] ||= image.url([:version]) html += tag(:img, ) if [:src] != 'missing.png' end end html end |