获取此错误(我已查看其他stackoverflow帖子)。我正在使用许可但仍然没有工作?
这些是注册表格中的参数(名字,姓氏,电话,电子邮件,密码,cc#,ccv,exp月,exp年)
ActiveModel::ForbiddenAttributesError (ActiveModel::ForbiddenAttributesError):
Nov 20 10:56:20 burro-staging app/web.1: app/controllers/requester_controller.rb:400:in `new'
Nov 20 10:56:20 burro-staging app/web.1: app/controllers/requester_controller.rb:400:in `create'
这是代码
def create
attributes = params[:user]
@user = User.new(book_params)
@cc_number = params[:cc_number]
@cc_cvv = params[:cc_cvv]
@cc_exp_month = params[:cc_exp_month]
@cc_exp_year = params[:cc_exp_year]
all_required = true
.....
attributes[:type] = User::PATIENT
last4 = nil
begin
last4 = params[:cc_number].gsub(/[^0-9]/i, '')[-4..-1]
rescue
last4 = nil
end
attributes[:last_4_credit_card] = last4
attributes[:cc_exp_date] = "#{params[:cc_exp_month]}# {params[:cc_exp_year]}"
r = User.create_new(book_params) <-- line 400
end
private
def book_params
params.require(:user).permit(:utf8, :authenticity_token, :cc_number, :cc_cvv, :cc_exp_month, :cc_exp_year, :email, :password, :last_name, :phone, :first_name)
end
我的模特
def self.create_new(attributes)
u = User.where(:email => attributes[:email].strip).first
....
end