Class: Spree::Api::V2::Storefront::HomepageSectionsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Api::V2::Storefront::HomepageSectionsController
- Defined in:
- app/controllers/spree/api/v2/storefront/homepage_sections_controller.rb
Instance Method Summary collapse
- #collection ⇒ Object
- #collection_serializer ⇒ Object
- #model_class ⇒ Object
- #preload_associations ⇒ Object
- #resource_serializer ⇒ Object
Instance Method Details
#collection ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/controllers/spree/api/v2/storefront/homepage_sections_controller.rb', line 18 def collection @collection = model_class.filter_by_segment(params[:homepage_id] || :general) .active .where(tenant_id: nil) .order(position: :asc) .includes(preload_associations) end |
#collection_serializer ⇒ Object
10 11 12 |
# File 'app/controllers/spree/api/v2/storefront/homepage_sections_controller.rb', line 10 def collection_serializer Spree::V2::Storefront::HomepageSectionSerializer end |
#model_class ⇒ Object
6 7 8 |
# File 'app/controllers/spree/api/v2/storefront/homepage_sections_controller.rb', line 6 def model_class SpreeCmCommissioner::HomepageSection end |
#preload_associations ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/spree/api/v2/storefront/homepage_sections_controller.rb', line 26 def preload_associations { homepage_section_relatables: { relatable: [ :icon, { home_banner: { attachment_attachment: :blob } }, { category_icon: { attachment_attachment: :blob } }, { video_banner: { attachment_attachment: :blob } }, { app_banner: { attachment_attachment: :blob } }, { web_banner: { attachment_attachment: :blob } }, { children: [ :icon, { vendors: [ { photos: { attachment_attachment: :blob } }, :default_state ] } ] } ] } } end |
#resource_serializer ⇒ Object
14 15 16 |
# File 'app/controllers/spree/api/v2/storefront/homepage_sections_controller.rb', line 14 def resource_serializer Spree::V2::Storefront::HomepageSectionSerializer end |