ext_81501: (Default)
Sidra ([identity profile] sidra.insanejournal.com) wrote in [community profile] rubyonrails 2009-04-18 07:35 pm (UTC)

Very nice writeup.

You might also want to add that since strings and symbols are not the same myhash[:key] != myhash["key"] for regular hashes.

That means if you copy your paramaters hash from the error page during testing with something like
> params={"key" => "value"}
when you paste your code from your controller which says
> if params[:key] == "value"
it will fail....

Rails has a special HashWithIndifferentAccess class just for the parameters :)
So, if you do
> params=HashWithIndifferentAccess.new
first, followed by
> params=params.merge({"key" => "value"})

then params[:key] == "value" will be true

Post a comment in response:

If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting