I´m new to Rails and I´ve been stuck trying to set the sign up on my rails application using devise gem. When I create the user the following error pops up:
ArgumentError in UsersController#create too few arguments
but the user still is created succesfully and added into the db.
This is my routes.rb file:
resources :users
devise_for :users
root to: 'static_pages#home'
get '/signup', to: 'users#new'
The create function in the users_controller.rb is:
@user = User.new(user_params)
if @user.save
format.html { redirect_to user_session_url(@user), notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
render 'new'
end
end
So far I noticed that when I swap the lines of resources :users with devise_for :users, it doesn´t throw me the error, but when listing all users it has only been saved the mails and password required by devise and not the other data of the user as the name, last name, etc.
This is my User.rb file:
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
validates :name, presence: true, length: {minimum:2, maximum:20}
validates :last_name, presence: true, length: {minimum:2, maximum:20}
end