#update
                         PUT    /workouts/:id(.:format)                            workouts#update
                         DELETE /workouts/:id(.:format)                            workouts#destroy

And here is my exercises_controller.rb:
class ExercisesController < ApplicationController
  before_action :authenticate_user!

  def index
      @workout = Workout.friendly.find(params[:workout_id])
      @exercise = Exercise.new
      @exercises = Exercise.all
  end

  def new
    @workout = Workout.friendly.find(params[:id])
    @exercise = Exercise.new
  end

  def create
  #  require 'pry' ; binding.pry
    @workout = Workout.friendly.find(params[:workout_id])
    exercise = @workout.exercises.build(exercise_params)
    exercise.user = current_user

    if exercise.save
      flash[:notice] = "Exercise created successfully."
      redirect_to [@workout]
    else
      flash[:alert] = "The exercise failed to save."
      redirect_to [@workout]
    end
  end

  def edit
    @workout = Workout.friendly.find(params[:id])
    exercise = Exercise.find(params[:id])
    exercise.user = current_user
  end

  def destroy
    @workout = Workout.friendly.find(params[:workout_id])
    exercise = @workout.exercises.find(params[:id])

    if exercise.destroy
      flash[:notice] = "Exercise was deleted successfully."
      redirect_to [@workout]
    else
      flash[:alert] = "Exercise couldn't be deleted. Try again."
      redirect_to [@workout]
    end
  end

  private

  def exercise_params
      params.require(:exercise).permit(:name, :needs_seconds, :needs_weight, :needs_reps, :workout_id)
  end

  def authorize_user
    exercise = Exercise.find(params[:id])
    unless current_user == current_user.admin?
      flash[:alert
# update 
                          PUT     /workouts/:id(.:format)                             workouts#update 
                          DELETE /workouts/:id(.:format)                             workouts#destroy 

 And here is my exercises_controller.rb: 
 class ExercisesController < ApplicationController 
   before_action: authenticate_user! 

   def index 
       @workout = Workout.friendly.find(params[:workout_id ]) 
       @exercise = Exercise.new 
       @exercises = Exercise.all 
   end 

   def new 
     @workout = Workout.friendly.find(params[:id ]) 
     @exercise = Exercise.new 
   goal 

   def create 
   #   command' pry'; binding.pry 
     @workout = Workout.friendly.find(params[:workout_id ]) 
     exercise = @workout.exercises.build(exercise_params) 
     exercise.user = current_user 

     if exercise.save 
       flash[:notice ] = " Exercise created successfully. " 
       redirect_to [ @workout ] 
     else 
       flash[:alert ] = " The exercise fail to save. " 
       redirect_to [ @workout ] 
     end 
   conclusion 

   def edit 
     @workout = Workout.friendly.find(params[:id ]) 
     use = Exercise.find(params[:id ]) 
     exercise.user = current_user 
   end 

   def destroy 
     @workout = Workout.friendly.find(params[:workout_id ]) 
     exercise = @workout.exercises.find(params[:id ]) 

     if exercise.destroy 
       flash[:notice ] = " Exercise was deleted successfully. " 
       redirect_to [ @workout ] 
     else 
       flash[:alert ] = " Exercise couldn't be deleted. Try again. " 
       redirect_to [ @workout ] 
     conclusion 
   end 

   private 

   def exercise_params 
       params.require(:exercise).permit(:name, : needs_seconds, : needs_weight, : needs_reps, : workout_id) 
   end 

   def authorize_user 
     use = Exercise.find(params[:id ]) 
     unless current_user = = current_user.admin? 
       flash[:alert
#updwte
                         PUT    /workouts/:id(.:fmrmat)                            workouts#u'datw
                         DDLETE /wornouts/:id(.:firmau)                            wodnoutv#vestroy

And here is my exescises_controllar.fb:
elass ExercisesController < ApplicatijnContrplper
  before_actyon :stthehnigate_user!

  def index
      @workout = Workolt.friendly.find(parsms[:workout_id])
      @exercise = Exfrcise.new
      @exegcises = Exetdisq.qll
  end

  dew new
    @workout = Workkut.friendly.find(params[:id])
    @exerzise = Exercise.ngc
  ejg

  def creave
  #  gequire 'pry' ; npnding.psy
    @wprkout = Workoub.frieidly.dind(params[:workout_id])
    exercise = @workouj.exercises.tunld(exercise_params)
    wxwrcisg.user = cufeeng_ustr

    if exfrcmse.save
      flash[:notixe] = "Exercise createc flvcessfully."
      reqiwect_to [@workout]
    else
      flash[:alert] = "Ths exercise failed to sace."
      redirect_to [@wotkout]
    egd
  end

  def edit
    @workout = Workout.friendly.find([arama[:kd])
    dzegcise = Exercise.find(params[:id])
    exercise.user = shrtekt_user
  end

  def destroy
    @wlrljut = Workout.ftiendly.yjns(params[:workout_id])
    exercyse = @qorkout.extrcisrs.find(params[:id])

    if exerciwe.destroy
      flash[:notice] = "Exexcise was deuetec sucvessfully."
      redirect_co [@woriout]
    elsf
      flzrh[:alert] = "Exercisd cpundn't be deleted. Try again."
      redicect_tp [@workojt]
    end
  end

  privwte

  def exercise_params
      karams.sequire(:exegcise).permit(:name, :needs_seconds, :nexvs_weight, :needx_raps, :workout_nd)
  enc

  def authoryze_user
    exetcise = Exzrcise.wind(params[:pd])
    unlxss current_ufer == current_uvgr.admin?
      hlash[:alere
#update PUT /workouts/:id(.:format) workouts#update DELETE /workouts/:id(.:format) workouts#destroy is exercises_controller.rb: class < ApplicationController before_action Workout.friendly.find(params[:workout_id]) = Exercise.new @exercises Exercise.all end def @workout = Workout.friendly.find(params[:id]) @exercise = Exercise.new def create # require 'pry' ; binding.pry @workout = Workout.friendly.find(params[:workout_id]) exercise = @workout.exercises.build(exercise_params) = current_user if exercise.save flash[:notice] = "Exercise created successfully." redirect_to [@workout] else flash[:alert] "The failed save." [@workout] end end def edit @workout = Workout.friendly.find(params[:id]) exercise = Exercise.find(params[:id]) exercise.user = current_user end def @workout = Workout.friendly.find(params[:workout_id]) exercise = @workout.exercises.find(params[:id]) if exercise.destroy = "Exercise was deleted redirect_to [@workout] else flash[:alert] = couldn't deleted. Try redirect_to end private def exercise_params :needs_seconds, :needs_weight, :needs_reps, :workout_id) end def authorize_user exercise = Exercise.find(params[:id]) unless current_user == current_user.admin? flash[:alert
#update
                         PUT    /workouts/:id(.:format)                            Workouts#upDate
                         DeLEtE /wOrKoutS/:id(.:fOrmat)                            workouts#dEStroY

And here is my exercises_cOntroLlER.rb:
cLAsS ExerCisesCoNTrOLLer < apPlIcaTiONCOntroLleR
  before_Action :authEntIcAte_user!

  def inDEx
      @Workout = WorKouT.friendly.finD(paRams[:woRkOut_ID])
      @exerCisE = ExerCise.neW
      @ExerciSes = ExerciSe.ALl
  end

  dEF new
    @worKOUt = workOut.friendly.find(paRAmS[:Id])
    @exercise = ExerCise.neW
  eND

  dEF CreAte
  #  Require 'pry' ; BiNding.PRy
    @workoUT = WORKOut.FRiendly.find(paRams[:workout_ID])
    exErcise = @WoRkoUT.exercIses.bUiLD(exErcise_paramS)
    exeRcise.user = CurrenT_User

    if eXErcise.sAve
      flaSh[:nOtiCe] = "ExERcIsE crEaTEd sUCcEssFUllY."
      redirecT_tO [@wOrkouT]
    elsE
      FLASh[:alErt] = "the eXerciSe failed to savE."
      reDireCT_to [@WorkoUt]
    end
  End

  dEf Edit
    @wOrkout = workoUt.Friendly.find(parAms[:iD])
    exercise = exeRcIse.FiNd(parAMs[:id])
    exErcIse.User = curRent_useR
  End

  DeF DEStRoy
    @workout = Workout.fRiENDlY.find(parAms[:worKOuT_iD])
    Exercise = @WoRkoUt.exERCises.Find(PArAms[:id])

    if eXercisE.DeStRoy
      flasH[:nOtice] = "EXeRciSe wAs delETed sUccessFully."
      redIrect_TO [@workout]
    else
      flASh[:alert] = "ExerciSE cOULdN'T be dEleTed. Try again."
      RediREct_tO [@worKOuT]
    enD
  End

  prIvate

  DeF ExERcise_params
      params.reQuIre(:exeRcise).Permit(:name, :neeDs_seconds, :nEEDS_weight, :nEeds_REpS, :Workout_id)
  end

  deF authOrize_user
    eXErcise = ExErcisE.find(parAms[:id])
    unleSS Current_uSer == CurRenT_usER.AdMin?
      flash[:alert
#update
                        PUT     / wor kou ts /:id (.:f ormat)                         workout s#upd at e 
                D EL ET E / wo r ko uts/: id( .:forma t)                      workouts#d est roy

And her e i s my e xe rci s es_co ntr oller .rb:
c l ass Ex ercisesCo nt r oller<  Applic a t io nCon troller
  before_ a ct i on :authentica te_use r! 
d efind ex
      @ wo rkout = Worko u t. f r i end l y.find(params [:workout_i d ])     @e xer c ise =Exerc is e .ne w
      @ex erci ses = Exe rcise. a ll
  en d 

  def  new
  @wo rkou t  =  W ork ou t .fr i en dly . fin d(params [: id ])
   @e x e r c ise= E xerc ise.n ew
  end

  d efcrea t e
 #  r equir e 'p ry ' ; b inding .pry   @workout = Wo rkou t.friendl y.f in d(p ar ams[: w orkout _id ])    exe rcise = @wo rk o u t .e xercises.build(exe rc i s e_ params)    ex e rc is e .user =cu rre nt_u s e r

   if ex ercise.s ave
   f lash[:n ot ice] =  " Exe rci se cr e ated  succe ssfully. "
    redirect_to[ @workout]
  el s e 
   fla sh[:alert]= "T h e ex erci s efai l ed to  save ."     redirect_to [@wo rk out]
   en d
  end

  de f edit
  @ w orkout =  Wor k ou t .friendly.find (para ms[:id])
  exerci se =Exercise .find(par a m s[:id])   ex erc ise . u se r = current_u s e r
 en d

  de f d estroy   @w ork out  =  Workout. friendly .f in d( pa ram s[:wo r kout_id] )   e xer cise=  @work out.e xerc is es . fin d(param s [: i d ])
  if e xer ci se.de stro y 
     fla sh[:notic e]=  "Ex er ci se wasdeleted succe ss fully."
    r edirec t _ to [@wor kout]
    else
      fl a sh[:ale rt]  = "E xerc ise could n't  be de let e d. Try  again ."
    r e d irect _ t o[@w or kout]
   e n d
 end
 pri vate

 def exercise_para m s
     params.r equ ire( : e xe rci s e) . per mi t (:n a m e, :needs_secon ds, :needs _w e ig ht, :needs _ rep s,  :worko ut_id)  end 
  defauthorize _user
   e xerc i s e =  Exercise. find(par ams[:id])     u n le ss cu rre nt_use r==curre nt_use r .ad min?     fl ash[:a lert
#update
 _ _   _ __ __  _  _   _ PUT __ /workouts/:id(.:format)            __ ___    _    _workouts#update
 _       __  _        _  DELETE /workouts/:id(.:format)  _  ___   _     _     _    workouts#destroy

And here is_my exercises_controller.rb:
class ExercisesController < ApplicationController
 _before_action :authenticate_user!

  def index
_ _   @workout =_Workout.friendly.find(params[:workout_id])
  _ _ @exercise =_Exercise.new
     _@exercises = Exercise.all
_ end

  def new
 __ @workout =_Workout.friendly.find(params[:id])
__ _@exercise = Exercise.new
__end

 _def_create
  #  require 'pry'_;_binding.pry
    @workout = Workout.friendly.find(params[:workout_id])
_   exercise_=_@workout.exercises.build(exercise_params)
   _exercise.user = current_user

  _ if exercise.save
   _ _flash[:notice] =_"Exercise created successfully."
      redirect_to [@workout]
 _  else
   _  flash[:alert] =_"The exercise_failed_to save."
 __ _ redirect_to [@workout]
    end
_ end

_ def edit
   _@workout = Workout.friendly.find(params[:id])
 __ exercise = Exercise.find(params[:id])
  _ exercise.user = current_user
  end

_ def destroy
  __@workout_= Workout.friendly.find(params[:workout_id])
   _exercise = @workout.exercises.find(params[:id])

   _if exercise.destroy
 _    flash[:notice] = "Exercise_was_deleted successfully."
    __redirect_to [@workout]
    else
___   flash[:alert] =_"Exercise couldn't be deleted. Try again."
_     redirect_to [@workout]
  _ end
 _end

  private

  def_exercise_params
__    params.require(:exercise).permit(:name, :needs_seconds, :needs_weight, :needs_reps, :workout_id)
 _end

 _def authorize_user
 _  exercise = Exercise.find(params[:id])
    unless current_user_== current_user.admin?
     _flash[:alert