diff --git a/app/controllers/coaches_controller.rb b/app/controllers/coaches_controller.rb index 1c1344d5..6c6eb326 100644 --- a/app/controllers/coaches_controller.rb +++ b/app/controllers/coaches_controller.rb @@ -10,25 +10,39 @@ def new def create @coach = Coach.new(coach_params) if @coach.save - redirect_to coach_url(@coach) + redirect_to edit_coach_path(@coach) else render :new end end + def edit + @coach = find_coach + end + + def update + @coach = Coach.find(params[:id]) + if !@coach.update(coach_params) + render :edit + end + end + def show - @user = current_user - @coach = @user.coach + @coach = Coach.find(params[:id]) end - + private - def coach_params - params.require(:coach).permit(:name, - :female, - :language_en, - :language_de, - :notifications, - user_attributes: [:email,:password]) - end - + def coach_params + params.require(:coach).permit(:name, + :female, + :language_en, + :language_de, + :notifications, + user_attributes: [:email,:password]) + end + + def find_coach + Coach.find(params[:id]) + end + end \ No newline at end of file diff --git a/app/views/coaches/edit.html.erb b/app/views/coaches/edit.html.erb new file mode 100644 index 00000000..21ef622e --- /dev/null +++ b/app/views/coaches/edit.html.erb @@ -0,0 +1,8 @@ +
Female | +<%= @coach.female %> | +
gives talks in German | +<%= @coach.language_de %> | +
gives talks in English | +<%= @coach.language_en %> | +