问题
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?
回答1:
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'
来源:https://stackoverflow.com/questions/5162395/uninitialized-constant-activesupportcoreextensions