Rails 4 strong parameters
ruby-on-rails, ruby-on-rails-4
Solution
I guess it existed way(way way before) before the release of rails 4 as a separate gem https://github.com/rails/strong_parameters
rails 4 have it by default ,if you want to use it with rails 3 , just get the gem in your gemfile and get going :).
on the github link of the gem , they also have written awesome documentaion on how to use it , so i guess you should not have any problems using it.
And ofcourse there is nothing new in it , you can do this filtering manually by writing your own filters and things may get a bit tricky with deeply nested hashes and array inside the hashes and if the keys of the hashes are dynamically created(not fixed)
""Yes, instead of only 1 line, it would take 3 lines"" and thats what most of the gems do , and we use them instead of reinventing the wheel and just concentating on our business logic.
Problem
It seems to be funny how Rails 4 deals with strong parameters: ``` def UsersController < ActionController::Base def update @user = current_user if @user.update_attributes(user_profile_parameters) redirect_to home_path, notice: "Your profile has been successfully updated." else render action: "edit" end end private def user_profile_parameters params.require(:user).permit(:name, :password, :password_confirmation, :email) end end ``` I wonder, isn't it possible in Rails 3? Yes, instead of only 1 line, it would take 3 lines, perhaps. But, there is nothing new there, it's just a manually created list of allowed parameters, in fact, it's just a hash, isn't it? Or is there any more deep purpose in it?