未初始化的常量 ActiveSupport::CoreExtensions [英] uninitialized constant ActiveSupport::CoreExtensions
问题描述
我正在尝试将 jquery 的 datepicker 与 formtastic 详细集成 这里
我完全按照说明操作,但是在运行此代码时出现未初始化的常量 ActiveSupport::CoreExtensions":
<%= semantic_form_for @item, :html =>{ :multipart =>真,:class =>'形式'} 做 |f|%><div class="group"><%= f.label :create_date, :class =>'标签'%><%= f.input :create_date, :as =>:日期选择器 %>
<%结束%>
我试图把它放在我的 config/application.rb 中:
需要'active_support/core_ext/date/conversions'
我已重新启动服务器,但仍然遇到相同的错误.我是否将这个 require 行放在正确的位置?
检查您链接的页面,我认为问题在于以下行:
format = options[:format] ||ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS[:default] ||%d %b %Y"
查看您提到的 文件,看来Rails现在直接修改了Date
类,而不是定义ActiveSupport::CoreExtensions::Date
;此外,将 :default
作为键传递给 DATE_FORMATS
似乎只是在对象上调用 to_default_s
.解决这个问题的最简单方法可能是删除对 ActiveSupport::CoreExtensions
的整个引用,因为代码还指定了一个默认值:
format = options[:format] ||%d %b %Y"
您还可以指定 Rails 在 conversions.rb
中添加的日期格式之一:
format = options[:format] ||日期::DATE_FORMATS[:rfc822] ||%d %b %Y"
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'
这篇关于未初始化的常量 ActiveSupport::CoreExtensions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!