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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jul-23 03:52 UTC
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. > > ... dougBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> But you are wrong AFAIK. params is a HashWithIndifferentAccess, so you > can use either symbols or strings.That settles the issue. Thanks. ...doug -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.