Signup II step 2


#1

Hi, can someone help me?
I know for sure that I did what it told me to do but I can't get passed step 2

Here's my code:

class UsersController < ApplicationController
  private
   def user_params
	params.require(:user).permit(:first_name, :last_name, :email, :password)
	end 
   def new
	@user = User.new
  end
end
def create 
  @user = User.new(user_params) 
  if @user.save 
    session[:user_id] = @user.id 
      redirect_to '/' 
  else 
     redirect_to '/signup' 
   end 
end

Did I do something wrong?

Error: Did you implement the create action? The action 'create' could not be found for UsersController

~Fiona~


#2

Hi Fiona,

You need to move the stuff in private down to just before the very last end in the file, I think :)
Also, be careful with your whitespace since Ruby depends on proper indentation for some stuff!


#3

Like this?

class UsersController < ApplicationController
    def new
	@user = User.new
    end
end
private
   def user_params
params.require(:user).permit(:first_name, :last_name, :email, :password)
   end
def create 
   @user = User.new(user_params) 
    if @user.save 
	session[:user_id] = @user.id 
	redirect_to '/' 
     else 
	redirect_to '/signup' 
    end 
end

#4

@javapro54590 Not quite. You need to move the second end down to the very bottom of the file, and private stuff still isn't at the bottom of UsersController.
private should come after create.


#5

Now It's giving me this error: wrong number of arguments (0 for 1)


#6

Could you create a new topic with your code, and I'll help you over there?
Thanks :)


#7

okay :smile: I'll make a new one