Accessing Input Type Image Coordinate Params

Form input of type image sends as parameters the x,y coordinates of
the point on the image where the click occurred. Param keys are
generally in the form, ‘my_image.x’ and ‘my_image.y’. So, if one
wants to test whether a particular image coordinate key is present he
would typically use something like:

params.has_key?(:my_image.x)

This results in a complaint that the ‘x’ method is not defined.
Presumably the problem is with the ‘.’ in the symbol name. Enclosing
the key name in single quotes works; but, I think that has been
deprecated. I’m wondering what is the best way of handling this.

Thanks for any input.

    ... doug

Doug J. wrote:

Form input of type image sends as parameters the x,y coordinates of
the point on the image where the click occurred. Param keys are
generally in the form, ‘my_image.x’ and ‘my_image.y’. So, if one
wants to test whether a particular image coordinate key is present he
would typically use something like:

params.has_key?(:my_image.x)

This results in a complaint that the ‘x’ method is not defined.
Presumably the problem is with the ‘.’ in the symbol name. Enclosing
the key name in single quotes works; but, I think that has been
deprecated.

But you are wrong AFAIK. params is a HashWithIndifferentAccess, so you
can use either symbols or strings.

I’m wondering what is the best way of handling this.

If you want to use a symbol, then review your basic Ruby syntax for
symbol literals. I recently dealt with this same issue in the post at
XML parsing, block name with minus - Rails - Ruby-Forum , so I’ll just refer you
there instead of typing the whole thing out again. Let me know if you
have any questions.

Thanks for any input.

    ... doug

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

But you are wrong AFAIK. params is a HashWithIndifferentAccess, so you
can use either symbols or strings.

That settles the issue. Thanks.

     ...doug