Class: RegionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RegionsController
- Defined in:
- app/controllers/regions_controller.rb
Instance Method Summary collapse
-
#children ⇒ Object
get /regions/:id/children.
-
#create ⇒ Object
post /regions.
-
#destroy ⇒ Object
delete /regions/:id.
-
#edit ⇒ Object
get /regions/:id/edit.
-
#index ⇒ Object
get /regions.
-
#show ⇒ Object
get /regions/:id.
-
#update ⇒ Object
patch /regions/:id.
Instance Method Details
#children ⇒ Object
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 |
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
get /regions/:id/edit
31 32 |
# File 'app/controllers/regions_controller.rb', line 31 def edit end |
#index ⇒ Object
get /regions
9 10 11 |
# File 'app/controllers/regions_controller.rb', line 9 def index @collection = Region.visible.for_tree end |
#show ⇒ Object
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 |
#update ⇒ Object
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 |