开发者

uninitialized constant ActiveSupport::CoreExtensions

开发者 https://www.devze.com 2023-02-14 10:08 出处:网络
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

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?


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'
0

精彩评论

暂无评论...
验证码 换一张
取 消