Class: Admin::GeoZonesController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::GeoZonesController
- Defined in:
- app/controllers/admin/geo_zones_controller.rb
Overview
This Controller Manage GeoZones
Instance Method Summary collapse
- #add_element ⇒ Object
-
#create ⇒ Object
Create a GeoZone ==== Params * geo_zone = Hash of GeoZone’s attributes.
-
#destroy ⇒ Object
Destroy a GeoZone ==== Params * id = ProductGeoZone’s id ==== Output if destroy succed, return the GeoZones list.
-
#edit ⇒ Object
Edit a GeoZone ==== Params * id = GeoZone’s id to edit * geo_zone = Hash of GeoZone’s attributes.
-
#index ⇒ Object
List GeoZones like a Tree.
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#add_element ⇒ Object
29 30 31 |
# File 'app/controllers/admin/geo_zones_controller.rb', line 29 def add_element render :text => @geo_zone.update_attribute(:transporter_rule_ids, @geo_zone.transporter_rule_ids << params[:element_id].to_i) end |
#create ⇒ Object
Create a GeoZone
Params
-
geo_zone = Hash of GeoZone’s attributes
The GeoZone can be a child of another GeoZone.
20 21 22 23 24 25 26 27 |
# File 'app/controllers/admin/geo_zones_controller.rb', line 20 def create if @geo_zone.save flash[:notice] = I18n.t('geo_zone.create.success').capitalize else flash[:error] = I18n.t('geo_zone.create.failed').capitalize end render :action => 'new', :layout => false end |
#destroy ⇒ Object
Destroy a GeoZone
Params
-
id = ProductGeoZone’s id
Output
if destroy succed, return the GeoZones list
56 57 58 59 60 61 62 |
# File 'app/controllers/admin/geo_zones_controller.rb', line 56 def destroy if @geo_zone.destroy flash[:notice] = I18n.t('geo_zone.destroy.success').capitalize else flash[:error] = I18n.t('geo_zone.destroy.failed').capitalize end end |
#edit ⇒ Object
Edit a GeoZone
Params
-
id = GeoZone’s id to edit
-
geo_zone = Hash of GeoZone’s attributes
The GeoZone can be a child of another GeoZone.
39 40 41 |
# File 'app/controllers/admin/geo_zones_controller.rb', line 39 def edit render :layout => false end |
#index ⇒ Object
List GeoZones like a Tree.
7 8 9 |
# File 'app/controllers/admin/geo_zones_controller.rb', line 7 def index @geo_zones = GeoZone.find_all_by_parent_id(nil) end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/admin/geo_zones_controller.rb', line 11 def new render :layout => false end |
#update ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/controllers/admin/geo_zones_controller.rb', line 43 def update if @geo_zone.update_attributes(params[:geo_zone]) flash[:notice] = I18n.t('geo_zone.update.success').capitalize else flash[:error] = I18n.t('geo_zone.update.failed').capitalize end render :action => 'edit', :layout => false end |