Class: RegionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/regions_controller.rb

Instance Method Summary collapse

Instance Method Details

#childrenObject

get /regions/:id/children



52
53
54
55
56
# File 'app/controllers/regions_controller.rb', line 52

def children
  @collection = Region.visible.for_tree(@entity.country_id, @entity.id)

  render :index
end

#createObject

post /regions



14
15
16
17
18
19
20
21
# File 'app/controllers/regions_controller.rb', line 14

def create
  @entity = Region.new(creation_parameters)
  if @entity.save
    form_processed_ok(admin_region_path(id: @entity.id))
  else
    form_processed_with_error(:new)
  end
end

#destroyObject

delete /regions/:id



44
45
46
47
48
49
# File 'app/controllers/regions_controller.rb', line 44

def destroy
  if @entity.destroy
    flash[:notice] = t('regions.destroy.success')
  end
  redirect_to admin_regions_path
end

#editObject

get /regions/:id/edit



31
32
# File 'app/controllers/regions_controller.rb', line 31

def edit
end

#indexObject

get /regions



9
10
11
# File 'app/controllers/regions_controller.rb', line 9

def index
  @collection = Region.visible.for_tree
end

#showObject

get /regions/:id



24
25
26
27
28
# File 'app/controllers/regions_controller.rb', line 24

def show
  unless @entity.visible
    handle_http_404('Region is not visible')
  end
end

#updateObject

patch /regions/:id



35
36
37
38
39
40
41
# File 'app/controllers/regions_controller.rb', line 35

def update
  if @entity.update(entity_parameters)
    form_processed_ok(admin_region_path(id: @entity.id))
  else
    form_processed_with_error(:edit)
  end
end