daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class RobotsController < ApplicationController
  2. # ADD THE FOLLOWING BEFORE_ACTION BELOW (I'VE COMMENTED OUT THE CORRESPONDING LINES FOR :SHOW, :EDIT, :UPDATE, :DESTROY)
  3.   before_action :current_robot, only: [:show, :edit, :update, :destroy]
  4.  
  5.   def index
  6.     @robots = Robot.all
  7.   end
  8.  
  9.   def show
  10.     # @robot = Robot.find(params[:id])
  11.   end
  12.  
  13.   def new
  14.     @robot = Robot.new
  15.   end
  16.  
  17.   def create
  18.     @robot = Robot.create(robot_params)
  19.  
  20.     redirect_to robot_path(@robot)
  21.   end
  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.   def destroy
  35.     # @robot = Robot.find(params[:id])
  36.     @robot.destroy
  37.  
  38.     redirect_to robots_path
  39.   end
  40.  
  41. private
  42.   def robot_params
  43.     params.require(:robot).permit(:name, :slogan)
  44.   end
  45.  
  46. # ADD THE FOLLOWING PRIVATE METHOD/ACTION BELOW
  47.  
  48.   def current_robot
  49.     @robot = Robot.find(params[:id])
  50.   end
  51.  
  52.  
  53. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top