# Accessing Input Type Image Coordinate Params

**URL:** <https://www.ruby-forum.com/t/accessing-input-type-image-coordinate-params/192055>\
**Category:** Rails\
**Created:** [July 23, 2010, 2:36am UTC](https://www.ruby-forum.com/t/accessing-input-type-image-coordinate-params/192055 "2010-07-23T02:36:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [July 23, 2010, 2:36am UTC](https://www.ruby-forum.com/t/accessing-input-type-image-coordinate-params/192055/1 "2010-07-23T02:36:01Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [July 23, 2010, 5:52am UTC](https://www.ruby-forum.com/t/accessing-input-type-image-coordinate-params/192055/2 "2010-07-23T05:52:21Z")

</div>

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](http://www.ruby-forum.com/topic/213388#926583) , 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](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [July 23, 2010, 7:31am UTC](https://www.ruby-forum.com/t/accessing-input-type-image-coordinate-params/192055/3 "2010-07-23T07:31:32Z")

</div>

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

That settles the issue. Thanks.

```
     ...doug
```
