aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/clean_ups_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/clean_ups_controller.rb')
-rw-r--r--app/controllers/clean_ups_controller.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/app/controllers/clean_ups_controller.rb b/app/controllers/clean_ups_controller.rb
index 8718fc0dc..c6e4ecd44 100644
--- a/app/controllers/clean_ups_controller.rb
+++ b/app/controllers/clean_ups_controller.rb
@@ -1,23 +1,19 @@
class CleanUpsController < ChouetteController
respond_to :html, :only => [:create]
-
belongs_to :referential
def create
- clean_up = CleanUp.new(params[:clean_up])
-
- if clean_up.invalid?
- flash[:alert] = clean_up.errors.full_messages.join("<br/>")
+ clean_up = CleanUp.new(clean_up_params)
+ clean_up.referential = @referential
+ if clean_up.valid?
+ clean_up.save
else
- begin
- result = clean_up.clean
- flash[:notice] = result.notice.join("<br/>")
- rescue => e
- Rails.logger.error "CleanUp failed : #{e} #{e.backtrace}"
- flash[:alert] = t('clean_ups.failure', error_message: e.to_s)
- end
+ flash[:alert] = clean_up.errors.full_messages.join("<br/>")
end
redirect_to referential_path(@referential)
end
+ def clean_up_params
+ params.require(:clean_up).permit(:keep_lines, :keep_stops, :keep_companies, :keep_networks, :keep_group_of_lines, :expected_date)
+ end
end