Rails 4 Strong Options: Allow All Attributes?

I am building a web application with strong Rails 4 options.

When creating back office admin controllers, I wonder what is the best way to allow all model attributes?

At the moment, I have written the following:

def user_params params.require(:user).permit(User.fields.keys) end 

What do you think is the best way?

+52
ruby-on-rails ruby-on-rails-3 strong-parameters
Dec 25
source share
1 answer

You can invoke the bang permission version.

 params.require(:user).permit! 

Strong Params README on Github

Source code for reference:

 def permit! each_pair do |key, value| convert_hashes_to_parameters(key, value) self[key].permit! if self[key].respond_to? :permit! end @permitted = true self end 
+113
Dec 26 '12 at 11:09
source share



All Articles