I am using Rails and angular 2 for my app, in my api rails I have added the
gem 'bcrypt', '~> 3.1.7'
my database table has password_digest: string
and my model has_secure_password
.
When I sent my form I get an error
Password can not be blank
Rails controller :
class UsersController < ApplicationController
def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
render json: @user, status: :created, location: @user
else
render json: @user.errors, status: :unprocessable_entity
end
end
private
def user_params
params.require(:user).permit(:first_name, :last_name, :email, :password)
end
end
Angular2 :
ngOnInit() {
this.Form = this.fb.group({
first_name: this.fb.control(null, Validators.required),
last_name: this.fb.control(null, Validators.required),
email: this.fb.control(null, Validators.required),
password: this.fb.control(null, Validators.required)
});
}