Class: Workarea::Admin::SegmentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/segments_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#destroyObject



33
34
35
36
37
38
39
# File 'app/controllers/workarea/admin/segments_controller.rb', line 33

def destroy
  head :unprocessable_entity && return if @segment.life_cycle?

  @segment.destroy
  flash[:success] = t('workarea.admin.segments.flash_messages.removed')
  redirect_to segments_path
end

#editObject



17
18
# File 'app/controllers/workarea/admin/segments_controller.rb', line 17

def edit
end

#indexObject



8
9
10
11
12
# File 'app/controllers/workarea/admin/segments_controller.rb', line 8

def index
  query = Search::AdminSegments.new(params)
  @search = SearchViewModel.new(query, view_model_options)
  @segments = SegmentViewModel.wrap(Segment.all, view_model_options)
end

#insightsObject



30
31
# File 'app/controllers/workarea/admin/segments_controller.rb', line 30

def insights
end

#showObject



14
15
# File 'app/controllers/workarea/admin/segments_controller.rb', line 14

def show
end

#updateObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/workarea/admin/segments_controller.rb', line 20

def update
  if @segment.update_attributes(params[:segment])
    flash[:success] = t('workarea.admin.segments.flash_messages.saved')
    redirect_to segment_path(@segment)
  else
    flash[:error] = @segment.errors.full_messages.to_sentence
    render :edit, status: :unprocessable_entity
  end
end