Class: Integral::Backend::PostsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/integral/backend/posts_controller.rb

Overview

Post management

Instance Method Summary collapse

Methods inherited from BaseController

#activities, #activity, #destroy, #edit, #index, #list, #show, #update

Instance Method Details

#createObject

POST / Resource creation



10
11
12
13
14
# File 'app/controllers/integral/backend/posts_controller.rb', line 10

def create
  super do
    @resource.active_block_list.listable = @resource
  end
end

#duplicateObject

POST /:id/duplicate Duplicate a resource



18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/integral/backend/posts_controller.rb', line 18

def duplicate
  super do |cloned_resource|
    cloned_resource.title = "Copy #{@resource.title[0...Integral.title_length_maximum - 5]}"
    cloned_resource.view_count = 0
    cloned_resource.build_active_block_list(content: @resource.active_block_list.content, listable: cloned_resource)
    cloned_resource.tag_list = @resource.tag_list_on(@resource.tag_context)
    cloned_resource.slug = @resource.slug
    cloned_resource.status = :draft
    cloned_resource.published_at = nil
  end
end

#newObject

GET /new Post creation screen



32
33
34
35
# File 'app/controllers/integral/backend/posts_controller.rb', line 32

def new
  super
  @resource.user = current_user
end