← Back to Upcase

Setup & Authentication

(Upcase ) #1

© 2012 - 2017 thoughtbot, inc. Upcase, the design of a robot, and thoughtbot are registered trademarks of thoughtbot, inc.

This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/intermediate-rails-1

(James Bush) #2

I copied everything but still get an error for the strong params in UsersController. Users#New calls user_params which requires :user, but params[:user] is not present until create. Any help is appreciated. Will the tutorial code be available? Thanks!

ActionController::ParameterMissing in UsersController#new
param is missing or the value is empty: user

(Anthony Nassar) #3

I am getting this problem too. Any solutions?

I don’t understand why its happening either, why is my user/new needing params?

(Tom Freudenheim) #4

I got the same error and I fixed it by over-riding new in the user controller (which had been referencing our over-written user_params method).

not sure why the one in Clearance was not like this, maybe I am limiting some special functionality with this change.

class UsersController < Clearance::UsersController

  def new
    @user = User.new
    render template: "users/new"


  def user_params
    params.require(:user).permit(:username, :email, :password)

(Tom Freudenheim) #5

Actually this is addressed/corrected in the 4th video

(Arslan Ali) #6

Author did a trick, and deleted a key-value pair in one go in Vim.

He had the following code: resources :users, controller: "clearance/users", only: [:create], and he deleted controller: "clearance/users", in one go. I’m interested in how he did that?

(Brett) #8

I’m getting ActiveModel::ForbiddenAttributesError when I add user_params to the UsersController, with following source:

  def sanitize_for_mass_assignment(attributes)
    if attributes.respond_to?(:permitted?)
      raise ActiveModel::ForbiddenAttributesError if !attributes.permitted?

Tried to find the author’s code on Github but nothing…I’ve followed exactly step by step, but stymied now. My Rails is a bit rusty, but this is rather annoying–any chance you can post sample code somewhere as a reference?

(Brett) #9

Okay, think I figured it out while re-watching. He did it very quickly in the video, missed it the first time: in the routes.rb file, he modified the original line:
resources :users, controller: "clearance/users", only: [:create] do

and removed the controller reference, so it reads like:

resources :users, only: [:create] do

Once I fixed that it worked fine.

But still: can you post example code? Thanks

(imtinge) #10

my finish repo

(Andrew Rodrigues) #11

I think it would be very helpful if you guys used a plugin to show the keys / shortcuts you are using! Otherwise, I have to pause and go search it myself, which isn’t a big deal, but it slows down the process going through the video. I know you guys have videos on vim, which I’m also going through.

Also, I was wondering how you would implement a constraint in the routes on your own outside of a gem used for authentication? I agree that using before_action isn’t as pretty as using a constraint in the routes.

You guys have great articles over here https://robots.thoughtbot.com/tags/rails. I think linking to articles you guys have created that cover these topics more in depth would be helpful to the user if they want to learn more through the resources you guys have already created.

(Andrew Rodrigues) #12

Can you post your code, or reference it? It’s difficult to help without seeing your code.

(Andrew Rodrigues) #13

Post or reference your code, I may be able to help! :stuck_out_tongue: