Class: Portfolio::SiteItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Portfolio::SiteItem
- Defined in:
- app/models/portfolio/site_item.rb
Direct Known Subclasses
Class Method Summary collapse
- .display_name ⇒ Object
- .group_by_categories ⇒ Object
- .human_name ⇒ Object
- .resource_name ⇒ Object
-
.subclasses ⇒ Object
overriding .subclasses because its an empty array at the time of constructing the routes.
- .subclasses_names ⇒ Object
Instance Method Summary collapse
- #default_image ⇒ Object
- #default_image_url(style = :medium) ⇒ Object
- #path_key ⇒ Object
- #path_title ⇒ Object
Class Method Details
.display_name ⇒ Object
54 55 56 |
# File 'app/models/portfolio/site_item.rb', line 54 def self.display_name nil end |
.group_by_categories ⇒ Object
40 41 42 |
# File 'app/models/portfolio/site_item.rb', line 40 def self.group_by_categories SiteItemCategory.where(id: self.select(:site_item_category_id)) end |
.human_name ⇒ Object
62 63 64 |
# File 'app/models/portfolio/site_item.rb', line 62 def self.human_name self.resource_name.split('_').last end |
.resource_name ⇒ Object
58 59 60 |
# File 'app/models/portfolio/site_item.rb', line 58 def self.resource_name self.name.underscore.split('/').last end |
.subclasses ⇒ Object
overriding .subclasses because its an empty array at the time of constructing the routes
46 47 48 |
# File 'app/models/portfolio/site_item.rb', line 46 def self.subclasses [SiteProject] end |
.subclasses_names ⇒ Object
50 51 52 |
# File 'app/models/portfolio/site_item.rb', line 50 def self.subclasses_names subclasses.map { |d| d.name.underscore.split('/').last } end |
Instance Method Details
#default_image ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/models/portfolio/site_item.rb', line 27 def default_image if site_item_images.empty? nil else site_item_images.default.first || site_item_images.first end end |
#default_image_url(style = :medium) ⇒ Object
35 36 37 38 |
# File 'app/models/portfolio/site_item.rb', line 35 def default_image_url style=:medium image = default_image image ? image.image.url(style) : nil end |
#path_key ⇒ Object
19 20 21 |
# File 'app/models/portfolio/site_item.rb', line 19 def path_key "#{path_title}-#{id}" end |
#path_title ⇒ Object
23 24 25 |
# File 'app/models/portfolio/site_item.rb', line 23 def path_title title.parameterize('-') end |