rails 4 strong params: make them conditional?

寵の児 提交于 2019-12-05 10:27:53

Does this achieve the desired results?

user_params = [ :user, :email, (:role if Rails.env.development?) ].compact
devise_parameter_sanitizer.for(:user) { |u| u.permit(*user_params) }
Rubytastic

Haven't found a solution, so I made 2 methods and call the correct param method to handle the records.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!