Class: Workarea::Admin::SegmentRulesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/segment_rules_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

#createObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/workarea/admin/segment_rules_controller.rb', line 15

def create
  if @rule.save
    flash[:success] = t('workarea.admin.segment_rules.flash_messages.saved')
    redirect_to return_to || segment_rules_path(@segment)
  else
    flash[:error] = t('workarea.admin.segment_rules.flash_messages.error')
    render :index, status: :unprocessable_entity
  end
end

#destroyObject



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

def destroy
  @rule.destroy
  flash[:success] = t('workarea.admin.segment_rules.flash_messages.destroyed')
  redirect_to return_to || segment_rules_path(@segment)
end

#geolocation_optionsObject



11
12
13
# File 'app/controllers/workarea/admin/segment_rules_controller.rb', line 11

def geolocation_options
  @results = Segment::Rules::GeolocationOption.search(params[:q])
end

#indexObject



8
9
# File 'app/controllers/workarea/admin/segment_rules_controller.rb', line 8

def index
end

#updateObject



25
26
27
28
29
30
31
32
33
# File 'app/controllers/workarea/admin/segment_rules_controller.rb', line 25

def update
  if @rule.update_attributes(params[:rule])
    flash[:success] = t('workarea.admin.segment_rules.flash_messages.saved')
    redirect_to return_to || segment_rules_path(@segment)
  else
    flash[:error] = t('workarea.admin.segment_rules.flash_messages.error')
    render :edit, status: :unprocessable_entity
  end
end