2013-10-18 39 views
5

我升级了应用程序到导轨4,一切工作正常。我可以登录并转到我的编辑页面。还更新了意见。当使用标准视图时,用户被更新。但是,当我添加例如字段:名称时,这不会在窗体中更新。设计与导轨4不更新用户

使用设计3.1.1,也是创业板protected_attributes“

我需要的色器件或DB运行某种更新命令的?

我也搜遍这个地方,找到许多不同的解决方案,但没有人会更新我的用户字段。我没有添加任何自定义字段。

+0

您是否尝试过使用rails 4 strong参数方法添加参数以查看是否通过? – trh

+0

在应用程序控制器中设置强参数。我最后一次尝试它没有,但在我删除了protected_attributes gem并重新启动服务器后,它工作:) – w25x

回答

8

如果您想要允许其他参数,您可以在ApplicationController中使用before filter,因为Rails 4将参数清理从模型移至控制器。

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

    protected 

    def configure_permitted_parameters 
    devise_parameter_sanitizer.for(:sign_up) << :name << :surname << :username 
    devise_parameter_sanitizer.for(:account_update) << :name << :surname << :username 
    end 
end 

您还可以找到更多here

+0

这和'devise_parameter_sanitizer.for(:sign_up){| u | u.permit(:username,:email,:password,:password_confirmation)}' – Un3qual