Guest User

Untitled

a guest
Jan 23rd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. class RobotsController < ApplicationController
  2.  
  3. def index
  4. @robots = Robot.all
  5. end
  6.  
  7. def show
  8. @robot = Robot.find(params[:id])
  9. end
  10.  
  11. def new
  12. @robot = Robot.new
  13. end
  14.  
  15. def create
  16. @robot = Robot.create(robot_params)
  17.  
  18. redirect_to robot_path(@robot)
  19. end
  20.  
  21. # ADD THE FOLLOWING METHOD/ACTIONS BELOW
  22.  
  23. def edit
  24. @robot = Robot.find(params[:id])
  25. end
  26.  
  27. def update
  28. @robot = Robot.find(params[:id])
  29. @robot.update
  30.  
  31. redirect_to robot_path(@robot)
  32. end
  33.  
  34. private
  35. def robot_params
  36. params.require(:robot).permit(:name, :slogan)
  37. end
  38.  
  39. end
Add Comment
Please, Sign In to add comment