Question

Rails 4.0.3. I have a form with a date field. In other words, it only works when I just use date_select. that works perfectly on my dev machine. When I deploy it to production, the form refuses to submit and throws a NoMethodError upon reaching the date, complaining about the lack of the utc method. I can't trace it because the production server's log never tells me more than the line where it fails, but that line is the Model.new(params[:form]) line and the failure is during the type conversion magic.

The field is currently a text field with the value supplied by jQuery UI datepicker, but this problem exists also when it is a plain Rails formhelper date_field. As soon as it gets to the date, it fails... but it works perfectly in dev and I'm deploying to production using Git, so I know we are on the same page.

Locally, I'm working in jRuby and using Neo4j.rb 2.3 as my DB. I have mimicked the dev environment by running the production app server, Torquebox, and it still local, fails remote. I'm running the same version of jRuby in both locations and I have all of my gems locked to specific versions to rule out some weird version-specific bug. Any thoughts are very appreciated!

Was it helpful?

Solution 2

I realized the solution AS SOON AS I was clicking the submit button but wanted to document this in case someone else ever has this issue. This is actually a bug in the neo4j-wrapper gem... that had a pull request merged two months ago... that I wrote. And I forgot about it. My local gemset still had my modified version of the gem cached, I guess, but the server was just using the latest release, which was done before my modification went in.

This bug is in type_converters.rb. Neo4j saves all times and dates to the DB as integers so it needs to convert whatever is submitted. The original code checked the type of the object to be converted. If it was a date, it converted it to a time and then ran utc; else, it just ran utc. This is obviously no good for strings, so my fix ran Time.parse(s) first.

So, if anyone else is having this issue and is using Neo4j.rb 2.3, add this line to your gemfile

gem 'neo4j-wrapper', git: 'https://github.com/andreasronge/neo4j-wrapper', ref: '00e5665ead'

OTHER TIPS

Try this code and see if it works:-

date_string = "#{review_params['date(1i)']}-#{review_params['date(2i)']}-#{review_params['date(3i)']}"
@concert = Concert.find_or_create_by!(artist: review_params[:artist], venue: review_params[:venue], date: date_string)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top