aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/stop_area_copies_controller.rb2
-rw-r--r--app/models/stop_area_copy.rb16
2 files changed, 9 insertions, 9 deletions
diff --git a/app/controllers/stop_area_copies_controller.rb b/app/controllers/stop_area_copies_controller.rb
index 7c1fac8d9..fb429595e 100644
--- a/app/controllers/stop_area_copies_controller.rb
+++ b/app/controllers/stop_area_copies_controller.rb
@@ -18,7 +18,7 @@ class StopAreaCopiesController < ChouetteController
@stop_area_copy = StopAreaCopy.new(params[:stop_area_copy])
@stop_area = parent
if @stop_area_copy.save
- redirect_to referential_stop_area_path( @referential,parent ), notice: I18n.t("stop_area_copies.new.success")
+ redirect_to referential_stop_area_path( @referential,@stop_area_copy.copy ), notice: I18n.t("stop_area_copies.new.success")
else
flash[:error] = I18n.t("stop_area_copies.errors.copy_aborted") + "<br>" + @stop_area_copy.errors.full_messages.join("<br>")
render :action => :new
diff --git a/app/models/stop_area_copy.rb b/app/models/stop_area_copy.rb
index 796aba567..041d30eb9 100644
--- a/app/models/stop_area_copy.rb
+++ b/app/models/stop_area_copy.rb
@@ -5,7 +5,7 @@ class StopAreaCopy
include ActiveModel::Conversion
extend ActiveModel::Naming
- attr_accessor :source_id, :hierarchy, :area_type, :source
+ attr_accessor :source_id, :hierarchy, :area_type, :source, :copy
validates_presence_of :source_id, :hierarchy, :area_type
@@ -40,17 +40,17 @@ class StopAreaCopy
begin
if self.valid?
self.source ||= Chouette::StopArea.find self.source_id
- copy = source.duplicate
- copy.name = source.name
- copy.area_type = self.area_type.camelcase
+ self.copy = source.duplicate
+ self.copy.name = source.name
+ self.copy.area_type = self.area_type.camelcase
Chouette::StopArea.transaction do
if self.hierarchy == "child"
- copy.parent_id = source.id
+ self.copy.parent_id = source.id
end
- copy.save!
+ self.copy.save!
if self.hierarchy == "parent"
- source.parent_id = copy.id
- source.save!
+ self.source.parent_id = copy.id
+ self.source.save!
end
end
true