gpt4 book ai didi

ruby - 没有填充 MongoDB/Mongoid 和 Rails 3 的 DateTime

转载 作者:IT老高 更新时间:2023-10-28 13:08:52 25 4
gpt4 key购买 nike

这是我模型中的代码

 include Mongoid::Document
include Mongoid::Timestamps

field :message, :type => String
field :send_at, :type => DateTime

这是我的表单部分代码

 <%= f.label :send_at %><br />
<%= f.datetime_select :send_at %>

但是从不填充日期和时间。我确保 Mongo 和 Mongoid 也是最新的。不知道我是否遗漏了什么。

[更新日志条目]

Started POST "/notifis" for 127.0.0.1 at Mon Oct 18 05:48:05 -0400 2010
Processing by NotifisController#create as HTML
Parameters: {"commit"=>"Create Notifi",
"authenticity_token"=>"/hrlnvA2Xn5NqGgCkPFAQV254IHPJEvZoLxOYNNUwhc=", "_snowman"=>"☃",
"notifi"=>{"send_at(2i)"=>"10", "is_sent"=>"0", "send_at(3i)"=>"18",
"send_at(4i)"=>"09", "message"=>"erwer", "send_at(5i)"=>"48",
"send_at(1i)"=>"2010"}}
MONGODB noti_development['notifis'].insert([{"send_at(2i)"=>"10", "created_at"=>Mon Oct
18 09:48:05 UTC 2010, "is_sent"=>false, "updated_at"=>Mon Oct 18 09:48:05 UTC 2010,
"_id"=>BSON::ObjectID('4cbc17d5c24d7602bc00002d'), "send_at(3i)"=>"18",
"message"=>"Sample Message", "send_at(4i)"=>"09", "send_at(1i)"=>"2010",
"send_at(5i)"=>"48"}])
Redirected to http://localhost:3000/notifis
Completed 302 Found in 4ms


Started GET "/notifis" for 127.0.0.1 at Mon Oct 18 05:48:05 -0400 2010
Processing by NotifisController#index as HTML
MONGODB
noti_development['users'].find({:_id=>BSON::ObjectID('4cb9db18c24d7602bc000007')},
{}).limit(-1)
MONGODB noti_development['notifis'].find({}, {})
Rendered notifis/index.html.erb within layouts/application (42.0ms)
Completed 200 OK in 52ms (Views: 51.2ms)

最佳答案

最新版本的 Mongoid 处理多参数属性,您只需在模型中包含模块:

include Mongoid::MultiParameterAttributes

文档:http://mongoid.org/en/mongoid/docs/rails.html

关于ruby - 没有填充 MongoDB/Mongoid 和 Rails 3 的 DateTime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3958052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com