Class: Cdx::Admin::PublishableResourceController

Inherits:
ResourceController show all
Defined in:
app/controllers/cdx/admin/publishable_resource_controller.rb

Direct Known Subclasses

PagesController

Instance Method Summary collapse

Methods inherited from ResourceController

belongs_to, #destroy, #edit, #index, #new

Methods inherited from BaseController

#authenticate_admin_user!, #current_ability, #meta_title

Methods inherited from Cdx::ApplicationController

#current_ability

Methods included from ControllerHelpers::Settings

#current_settings

Methods included from ControllerHelpers::Seo

#canonical_url, #contextual_record, #meta_data, #meta_title, #open_graph_data

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/cdx/admin/publishable_resource_controller.rb', line 16

def create
  @object.assign_attributes permitted_resource_params

  if @object.send current_action
    flash_message(@object, :create, :success)
    redirect_to location_after_save
  else
    flash_message(@object, :create, :error)
    render :new
  end
end

#updateObject



4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/cdx/admin/publishable_resource_controller.rb', line 4

def update
  @object.assign_attributes permitted_resource_params

  if @object.send current_action
    flash_message(@object, (current_action == :save ? :update : current_action), :success)
    redirect_to location_after_save
  else
    flash_message(@object, (current_action == :save ? :update : current_action), :error)
    render :edit
  end
end