Class: Katalyst::Content::ItemsController

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

Direct Known Subclasses

TablesController

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



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

def container
  @container
end

#editorObject (readonly)

Returns the value of attribute editor.



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

def editor
  @editor
end

#itemObject (readonly)

Returns the value of attribute item.



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

def item
  @item
end

Instance Method Details

#createObject



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

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



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

def edit
  render_editor
end

#newObject



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

def new
  render_editor
end

#updateObject



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

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