On May 23, 2009, at 7:40 PM, Damian Janowski wrote:
> How about a simple extension to Hash (somebody let me know if this > exists already) that allows you to do: > > user.attributes = params[:user].pick(:first_name, :last_name) This is what active support #slice and #slice! hash extensions do and I have used this in my controllers already for mass attribute white lists per controller action "when needed" for a few months now. I think since 2.3.2 (perhaps earlier) the #slice method even do as expected for indifferent access hashes. >> {'a' => 'fff', 'b' => 'ccc'}.with_indifferent_access.slice(:a) => {"a"=>"fff"} - Ken --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---