Class: Spree::PostsController
- Inherits:
-
StoreController
- Object
- BaseController
- StoreController
- Spree::PostsController
- Defined in:
- app/controllers/spree/posts_controller.rb
Instance Method Summary collapse
Methods inherited from StoreController
#current_taxon, #default_products_sort, #permitted_products_params, #products_filters_params, #render_404_if_store_not_exists, #store_filter_names, #store_filter_names_hash
Methods included from AnalyticsHelper
#analytics_event_handlers, #track_event, #unsupported_event?, #visitor_id
Methods included from WishlistHelper
Methods included from PasswordProtected
Methods included from StorefrontHelper
#as_aspect_ratio, #page_description, #page_image, #paths_equal?, #render_storefront_partials, #show_account_pane?, #spree_storefront_base_cache_key, #spree_storefront_base_cache_scope, #svg_country_icon, #tailwind_classes_for
Methods included from ThemeConcern
#default_url_options, #set_theme_view_paths
Instance Method Details
#index ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/spree/posts_controller.rb', line 8 def index @current_page = current_theme.pages.find_by!(type: 'Spree::Pages::PostList') scope = current_store.posts.published scope = scope.tagged_with(@tag.name) if @tag.present? scope = scope.where(post_category_id: @category.id) if @category.present? sorted_posts = scope.order(published_at: :desc) @posts = paginate_collection(sorted_posts, limit: 20) end |
#related_products ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/spree/posts_controller.rb', line 32 def @post = Spree::Post.friendly.find(params[:id]) current_page = current_theme.pages.find_by!(type: 'Spree::Pages::Post') @section = current_page.sections.find_by!(id: params[:section_id], type: 'Spree::PageSections::RelatedProducts') end |
#show ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/spree/posts_controller.rb', line 19 def show if params[:preview_id].present? preview_post = current_store.posts.friendly.find(params[:id]) raise ActiveRecord::RecordNotFound if preview_post.id.to_s != params[:preview_id] @post ||= preview_post else @post = current_store.posts.friendly.published.find(params[:id]) end @current_page = current_theme.pages.find_by!(type: 'Spree::Pages::Post') end |