diff options
| author | Luc Donnet | 2017-07-07 18:19:50 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-07-07 18:19:50 +0200 |
| commit | 24977a51e49a3d88cf36d1fd71e2ddc51c4ec6e5 (patch) | |
| tree | 87512253a6a7badc376998622f1e57776c2e54cf /app/controllers | |
| parent | 42f5fbc1c93a79310458fc3c299192fb44556101 (diff) | |
| download | chouette-core-24977a51e49a3d88cf36d1fd71e2ddc51c4ec6e5.tar.bz2 | |
Fix routing_constraint_zone validation for create refs #3962 @3
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/routing_constraint_zones_controller.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index 1eb2ddf28..c526e6348 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -22,14 +22,20 @@ class RoutingConstraintZonesController < ChouetteController def new new! do |format| format.html - @route = @line.routes.find params[:route_id] if params[:route_id] - format.js + format.js { + # Get selected route in the form view + @route = @line.routes.find params[:route_id] if params[:route_id] + # Get the routing_constraint_zone, the main use is when validation failed + routing_constraint_zone = @line.routing_constraint_zones.new(JSON(params[:routing_constraint_zone_json])) if params[:routing_constraint_zone_json] + @routing_constraint_zone = routing_constraint_zone || build_resource + } end end protected alias_method :routing_constraint_zone, :resource + alias_method :line, :parent def collection @q = current_referential.routing_constraint_zones.search(params[:q]) |
