aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorXinhui2017-03-30 14:55:06 +0200
committerXinhui2017-03-30 14:55:45 +0200
commit869ba13f7bbd72f197737ffe2a2c234fb73a5059 (patch)
tree43a4739666b99fd3b3dcc9c74c68130e5bdf81f4 /app/controllers
parentfb583e5fb235a3f04558e94ec1aa933460faa82c (diff)
downloadchouette-core-869ba13f7bbd72f197737ffe2a2c234fb73a5059.tar.bz2
Fix route form opposite_route option should be based on wayback selection
Refs #2839
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/routes_controller.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 6a38b022d..a1aadf883 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -9,8 +9,7 @@ class RoutesController < ChouetteController
belongs_to :referential do
belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true
end
-
- before_action :define_candidate_opposite_routes, only: [:new, :edit, :create, :update]
+ before_action :define_candidate_opposite_routes, only: [:new, :edit]
def index
index! do |format|
@@ -66,11 +65,11 @@ class RoutesController < ChouetteController
end
end
-# def update
-# update! do |success, failure|
-# success.html { redirect_to referential_line_path(@referential,@line) }
-# end
-# end
+ # def update
+ # update! do |success, failure|
+ # success.html { redirect_to referential_line_path(@referential,@line) }
+ # end
+ # end
protected
alias_method :route, :resource
@@ -86,12 +85,13 @@ class RoutesController < ChouetteController
end
def define_candidate_opposite_routes
- @candidate_opposite_routes =
- if params[:id]
- resource.line.routes.where("id <> ?", resource)
- else
- parent.routes.select(&:persisted?)
- end
+ scope = if params[:id]
+ parent.routes.where(opposite_route: [nil, resource]).where('id <> ?', resource.id)
+ else
+ parent.routes.where(opposite_route: nil)
+ end
+ @forward = scope.where(wayback: :straight_forward)
+ @backward = scope.where(wayback: :backward)
end
private