albertopq / jquery_datepicker

Rails 3 plugin that allows you to select dates from a calendar
91 stars 60 forks source link

html_escape not found #6

Closed triemstr closed 12 years ago

triemstr commented 13 years ago

Hi I'm getting an exception that is difficult for me to figure out. The gem works fine when I do a get request on my page but after submission, when the record is invalid, the return to the page throws an exception:

-------------------------------
Backtrace:
-------------------------------
  undefined method `html_escape' for #<JqueryDatepicker::InstanceTag:0x63dfc50>

  jquery_datepicker (0.3.0) lib/app/helpers/form_helper.rb:41:in `get_to_input_field_tag_options'
  jquery_datepicker (0.3.0) lib/app/helpers/form_helper.rb:11:in `datepicker'
  jquery_datepicker (0.3.0) lib/app/helpers/form_helper.rb:23:in `datepicker'
  app/views/listings/new_supply.html.erb:113:in `block (2 levels) in _app_views_listings_new_supply_html_erb__312169607_49857096'

Is there some reason why this doesn't work when there is a failed save? I imagine I may be doing something wrong, but at the same time, I changed html_escape in form_helper to:

ERB::Util.html_escape

and it worked.

Any chance you can update the gem and put another one out with that change? If you have any other thoughts, I'm all ears.

Kevin

triemstr commented 13 years ago

Also, I'm assuming html_escape is meant to be from ERB, but I'm not sure on that either. I'm using 1.9.2 by the way...hopefully this change works with 1.9.3's ERB as well.

albertopq commented 13 years ago

Thanks again for your feedback Kevin.

What happened is that I was using a previous version of the "to_input_field_tag" method (http://rubydoc.info/docs/rails/3.0.0/ActionView/Helpers/InstanceTagMethods:to_input_field_tag) that didn't include the ERB::Util. That made me thing that is not a good thing to depend on that method, so now I'm extracting only the name and id from a private method, and Rails is who generate the options without me updating that method every time they change it.

Hope this fixes any other future dependency as well.

I'm going to publish a new version right now. Cheers!