title: Allowing additional parameters for admin accounts
body: <p>I have a number of models with attributes that ordinary users should not be able to change, but admins should. For example (though this is not my problem domain), normal users should not be able to change a <code>Post</code>'s <code>user_id</code>, but administrators should be allowed to do so.</p>
  
  <p>Handling this at the view level is simple enough—I can show or not show fields depending on whether the user is an administrator—but I'm not sure how to handle it in the controller's strong parameter handling. The only solution I can come up with (and the solution <a href="https://stackoverflow.com/questions/22112461/rails-4-mass-assignment-whitelisting-parameters-for-admin-user">offered previously</a>) is to Repeat Yourself, something you try to Don't in Rails:</p>
  
  <pre><code>def post_params
    if admin?
      params.require(:post).permit(:title, :text, :date, :user_id)
    else
      params.require(:post).permit(:title, :text, :date)
   end
  end
  </code></pre>
  
  <p>Is there a better way to handle this?</p>