Protected_rewriter is a Ruby on Rails plugin for handling protected attributes written by stevo.
Imagine you have many protected attributes in your Rails application model and you have to assign them in your controller, like in this example:
Imagine you have many protected attributes in your Rails application model and you have to assign them in your controller, like in this example:
def update @user = User.find_by_id(params[:id]) @user.is_admin = params[:user][:is_admin] @user.hidden = params[:user][:hidden] @user.active = params[:user][:active] @user.redmine_user_id = params[:user][:redmine_user_id] update! end
Gosh, it’s so much typing! But here protected_rewriter plugin comes for the rescue stevo, it’s creator saves the day. By including a ProtectedRewriter module in your controller you may rewrite a previous Rails controller like this:
def update @user = User.find_by_id(params[:id]) rewrite_params(@user, :is_admin, :hidden, :active, :redmine_user_id) update! end Cool, isn’t it? Go and grab it from github: <a href="http://github.com/stevo/protected_rewriter">http://github.com/stevo/protected_rewriter</a> or you can use this url <a href="http://github.com/stevo/protected_rewriter.git.">http://github.com/stevo/protected_rewriter.git.</a>
