Easy part:
I have model with protected attribute and I have action which can be accessed only by admin, how to force assigning all attributes, so I don't need to do something like this:
@post = Post.find(params[:id])
if params[:post].is_a?(Hash) && params[:post][:published]
@post.published = params[:post].delete(:published) # delete is to skip warning about protected attribute assignment in update_attributes
end
if @order.update_attributes(params[:post])
…
Harder part:
I have model with a lot of protected attributes and multiple types of users, some of them could assign only unprotected attributes, some can change only part of protected attributes and some can change all attributes. How to write small readable code in this case without reinventing the wheel?