Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninitialized constant ActiveSupport::CoreExtensions

I'm attempting to integrate jquery's datepicker with formtastic as detailed here

I've followed the directions exactly, but am getting "uninitialized constant ActiveSupport::CoreExtensions" when running this code:

<%= semantic_form_for @item, :html => { :multipart => true, :class => 'form'} do |f| %>
 <div class="group">
  <%= f.label :create_date, :class => 'label' %>
  <%= f.input :create_date, :as => :datepicker %>
 </div>
<% end %>

I attempted to put this in my config/application.rb:

require 'active_support/core_ext/date/conversions'

I've restarted the server but am still getting the same error. Am I putting this require line in the correct place?

like image 224
panzhuli Avatar asked Mar 02 '11 01:03

panzhuli


1 Answers

Checking the page you linked, I assume the problem is the following line:

format = options[:format] || ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS[:default] || '%d %b %Y'

Looking at the file you mentioned, it appears that Rails now modifies the Date class directly rather than defining ActiveSupport::CoreExtensions::Date; furthermore, passing :default as the key to DATE_FORMATS appears to just call to_default_s on the object. The easiest way to deal with this would probably be to remove the whole reference to ActiveSupport::CoreExtensions, since the code also specifies a default:

format = options[:format] || '%d %b %Y'

You could also specify one of the date formats Rails adds in conversions.rb as so:

format = options[:format] || Date::DATE_FORMATS[:rfc822] || '%d %b %Y'
like image 145
Michelle Tilley Avatar answered Sep 28 '22 07:09

Michelle Tilley