用于设计帐户更新的rails中的应用程序控制器

时间:2014-08-28 09:54:49

标签: ruby-on-rails devise

我正在尝试向编辑用户部分添加一些其他字段。在应用程序控制器中,我一直在查看强参数。它工作时,我只是有额外的名称字段,但现在我添加额外的字段,它在我身上抛出以下错误,我不太确定我需要修改这里来解决这个问题。

/application_controller.rb:12: syntax error, unexpected ',', expecting keyword_end ....for(:account_update) << :name, :line1, :line2, :town, :coun... ... ^


class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

   before_filter :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :name
    devise_parameter_sanitizer.for(:account_update) << :name, :line1, :line2, :town, :county, :postcode
  end
end

1 个答案:

答案 0 :(得分:1)

试试这样:

 def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name) }
    devise_parameter_sanitizer.for(:account_update) { |u| u.permit(name, :line1, :line2, :town, :county, :postcode)}
 end