未初始化的常量 ActiveSupport::CoreExtensions
我正在尝试将 jquery 的 datepicker 与 formattastic 集成,详细信息此处< /a>
我完全按照说明进行操作,但在运行此代码时收到“未初始化的常量 ActiveSupport::CoreExtensions”:
<%= 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 %>
我试图将其放入我的 config/application.rb:
require 'active_support/core_ext/date/conversions'
我已重新启动服务器,但仍然得到同样的错误。我是否将此要求行放在正确的位置?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您链接的页面,我认为问题出在以下行:
查看 您提到的文件,看来 Rails 现在直接修改
Date
类,而不是定义ActiveSupport::CoreExtensions::Date
;此外,将:default
作为键传递给DATE_FORMATS
似乎只是在对象上调用to_default_s
。处理这个问题最简单的方法可能是删除对ActiveSupport::CoreExtensions
的整个引用,因为代码还指定了默认值:您还可以指定 Rails 在
中添加的日期格式之一>conversions.rb
如下:Checking the page you linked, I assume the problem is the following line:
Looking at the file you mentioned, it appears that Rails now modifies the
Date
class directly rather than definingActiveSupport::CoreExtensions::Date
; furthermore, passing:default
as the key toDATE_FORMATS
appears to just callto_default_s
on the object. The easiest way to deal with this would probably be to remove the whole reference toActiveSupport::CoreExtensions
, since the code also specifies a default:You could also specify one of the date formats Rails adds in
conversions.rb
as so: