[Rails] Re: Accessing Input Type Image Coordinate Params
Doug Jolley 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
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
marnen@marnen.org
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home