Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在轨道4中使用Desive的未经许可的参数_Ruby On Rails_Ruby On Rails 4_Devise - Fatal编程技术网

Ruby on rails 在轨道4中使用Desive的未经许可的参数

Ruby on rails 在轨道4中使用Desive的未经许可的参数,ruby-on-rails,ruby-on-rails-4,devise,Ruby On Rails,Ruby On Rails 4,Devise,最近从Rails 3更新到Rails 4,我目前在Desive中遇到了自定义字段的问题。我已经阅读了有关stackoverflow的文档和许多帖子,但似乎仍然存在一些问题 我在服务器日志中看到的错误如下: Unpermitted parameters: f_name, l_name, phone ArgumentError (wrong number of arguments (0 for 1)): 有人能在这里发现问题吗 # controllers/users/registrations_c

最近从Rails 3更新到Rails 4,我目前在Desive中遇到了自定义字段的问题。我已经阅读了有关stackoverflow的文档和许多帖子,但似乎仍然存在一些问题

我在服务器日志中看到的错误如下:

Unpermitted parameters: f_name, l_name, phone
ArgumentError (wrong number of arguments (0 for 1)):
有人能在这里发现问题吗

# controllers/users/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController
 before_filter :configure_permitted_parameters

 protected

 def configure_permitted_parameters
  devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:f_name, :l_name, :phone) }
 end
end

#routes.rb
devise_for :users, controllers: { registrations: "users/registrations" }

请将您的方法放入应用程序控制器

class ApplicationController < ActionController::Base
 before_action :configure_permitted_parameters, if: :devise_controller?

 protected

  def configure_permitted_parameters
   devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:f_name, :l_name, :phone, :email, :password) }
  end
end
class ApplicationController

请查看

中的Desive Strong Parameter concept(设计强参数概念)当我使用上述方法时,我不再收到
未经允许的参数:f\u name、l\u name、phone
错误,但我仍然存在
ArgumentError(参数数量错误(0代表1))
问题。有什么想法吗?我很感激你的努力,但这不起作用。。我再次收到相同的错误
未经允许的参数:f_name、l_name、phone
ArgumentError(参数数量错误(0代表1))
更新:我从注册页面删除了自定义字段,并继续收到
ArgumentError(参数数量错误(0代表1))
错误,这让我相信这个问题与自定义字段几乎没有关系,或者根本没有关系。首先删除自定义控制器和自定义路由,然后按照我上面提到的那样放置代码并进行检查。我可以在github或其他任何地方查看您的代码吗?因此,我可以更好地帮助您。更新:我从注册页面中删除了自定义字段,并继续收到ArgumentError(错误的参数数(0代表1))错误,这使我相信问题与自定义字段几乎没有关系
class ApplicationController < ActionController::Base
 before_action :configure_permitted_parameters, if: :devise_controller?

 protected

  def configure_permitted_parameters
   devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:f_name, :l_name, :phone, :email, :password) }
  end
end