From c2c108ca0745a54c805a1b1818dd1f78f1029b95 Mon Sep 17 00:00:00 2001 From: Andrew Radev Date: Sat, 30 May 2015 17:18:28 +0300 Subject: [PATCH] Set active conference upon creation --- .../management/conferences_controller.rb | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/app/controllers/management/conferences_controller.rb b/app/controllers/management/conferences_controller.rb index 1d2feb9..1a68d9d 100644 --- a/app/controllers/management/conferences_controller.rb +++ b/app/controllers/management/conferences_controller.rb @@ -10,9 +10,10 @@ module Management end def create - @conference = Conference.new conference_params + @conference = Conference.new(conference_params) if @conference.save + set_current_conference(@conference) redirect_to [:management, @conference] else render :new @@ -20,7 +21,7 @@ module Management end def update - @conference.update conference_params + @conference.update(conference_params) @conference.save render :edit end @@ -65,20 +66,11 @@ module Management end def conference_params - params.require(:conference).permit [:title, - :email, - :start_date, - :end_date, - :description, - tracks_attributes: [:id, - :name, - :color, - :description, - :_destroy], - halls_attributes: [:id, - :name, - :_destroy] - ] + params.require(:conference).permit( + :title, :email, :start_date, :end_date, :description, + tracks_attributes: [:id, :name, :color, :description, :_destroy], + halls_attributes: [:id, :name, :_destroy] + ) end end end