Class: Workarea::Storefront::ContentBlocksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/storefront/content_blocks_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_layout, #current_user_info, #health_check, #layout_content

Methods included from OrderLookup

#lookup_order, #lookup_order=

Methods included from UserActivity

#current_user_activity_id, #user_activity

Methods included from CurrentCheckout

#clear_current_order, #completed_order, #completed_order=, #current_checkout, #current_order, #current_order=, #current_shipping, #current_shippings

Methods included from HttpCaching

#cache_page, #http_caching?

Instance Method Details

#draftObject



25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/workarea/storefront/content_blocks_controller.rb', line 25

def draft
  draft = Content::BlockDraft.find(params[:id])

  @content = draft.content
  @block = Storefront::ContentBlockViewModel.wrap(
    draft.to_block,
    view_model_options
  )

  render :show
end

#newObject



9
10
11
12
13
14
15
16
# File 'app/controllers/workarea/storefront/content_blocks_controller.rb', line 9

def new
  @content = Content.find(params[:content_id])
  block = @content.blocks.build(type_id: params[:type_id])
  block.data = block.type.defaults
  @block = Storefront::ContentBlockViewModel.wrap(block, view_model_options)

  render :show
end

#showObject



18
19
20
21
22
23
# File 'app/controllers/workarea/storefront/content_blocks_controller.rb', line 18

def show
  @content = Content.from_block(params[:id])
  block = @content.blocks.find(params[:id])

  @block = Storefront::ContentBlockViewModel.wrap(block, view_model_options)
end