app/models/activeadmin_selleo_cms/section.rb in activeadmin-selleo-cms-0.0.14 vs app/models/activeadmin_selleo_cms/section.rb in activeadmin-selleo-cms-0.0.16
- old
+ new
@@ -12,10 +12,26 @@
validates_presence_of :name
validates_uniqueness_of :name, scope: [:sectionable_type, :sectionable_id]
validates_associated :translations
+ scope :with_name, ->(section_name) { where(name: section_name) }
+ scope :blurbs, where("name ILIKE 'blurb.%'")
+ scope :help, where("name ILIKE 'help.%'")
+
+ def toolbar
+ case name
+ when /blurb\./ then "Easy"
+ when /help\./ then "Lite"
+ else "Easy"
+ end
+ end
+
class Translation
attr_protected :id
+
+ has_many :attachments, as: :assetable
+
+ accepts_nested_attributes_for :attachments
end
end
end