Hello guys I have a Model with field DateTime like:
include Mongoid::Document
include Mongoid::MultiParameterAttributes
field :published_on, :type => DateTime
In my _form.html.erb I have like:
<div class="field">
<%= f.label :published_on %><br %>
<%= f.date_select :published_on %>
</div>
.
.
.
.
When I go to create the new article I can see开发者_StackOverflow社区 the field select Date, but I want create a new article with the date, but without I can create or edit manually the date.
Its mean, in stackoverflow for example, if I create a new question, appear the date but I can not see a field select datetime I can not edit field too.
Its possible add to my database mongodb a Date and Time to create new article without appear a datetime select in my views new and edit?
Its possible hide the field date_select and add the date to database?
Why not use the default Mongoid timestamps that add created_at on save. Granted this timestamp is only created when the record is saved, but it is a non changeable date and time. Simply add include Mongoid::Timestamps
to your model, and then on your show page you can just access created_at
to show it.
精彩评论