Class: Katalyst::Content::ItemsController

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/katalyst/content/items_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



10
11
12
# File 'app/controllers/katalyst/content/items_controller.rb', line 10

def container
  @container
end

#editorObject (readonly)

Returns the value of attribute editor.



10
11
12
# File 'app/controllers/katalyst/content/items_controller.rb', line 10

def editor
  @editor
end

#itemObject (readonly)

Returns the value of attribute item.



10
11
12
# File 'app/controllers/katalyst/content/items_controller.rb', line 10

def item
  @item
end

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/katalyst/content/items_controller.rb', line 22

def create
  if item.save
    render :update, locals: { editor:, item:, previous: @container.items.build(type: item.type) }
  else
    store_attachments(item)

    render_editor status: :unprocessable_entity
  end
end

#editObject



18
19
20
# File 'app/controllers/katalyst/content/items_controller.rb', line 18

def edit
  render_editor
end

#newObject



14
15
16
# File 'app/controllers/katalyst/content/items_controller.rb', line 14

def new
  render_editor
end

#updateObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/katalyst/content/items_controller.rb', line 32

def update
  @item.attributes = item_params

  if @item.valid?
    previous = @item
    @item    = @item.dup.tap(&:save!)

    render locals: { editor:, item:, previous: }
  else
    store_attachments(item)

    render_editor status: :unprocessable_entity
  end
end