[Rails-core] RFC: Safely accessing the params hash

Caio Chassot
2005-08-08T16:59:03Z

>   employee.task_ids = params[:employee][:task_ids]
>
> On a sunny day it''ll even work. As params[:employee] can be nil,
> there''s
> a lurking failure.

I''ve implemented a solution to this, perhaps similar to yours, that
went like:

   hash.get_deep(:employee, :task_id)

If a lookup fails at any point, nil is returned.

And I''ve considered overriding Hash#[] to take multiple parameters,
implementing the same functionality

   hash[:employee, :task_id]

Not sure if having either built-in is a good idea, though.