我想使用ruby论坛助手设置日期时间字段。使用Ruby表单助手设置日期时间字段
<%= form_for @event do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<strong>Title</strong>
<div class="field">
<%= f.text_field :title %>
</div>
<strong>Description</strong>
<div class="field">
<%= f.text_area :description, :class => "comment" %>
</div>
<strong>Location</strong>
<div class="field">
<%= f.text_field :location %>
</div>
<strong>Time</strong>
<div class="field">
<%= select_datetime Date.today, :prefix => :start_date %>
</div>
<div class="actions">
<%= f.submit "Add Event" %>
</div>
<% end %>
在控制器我这样做: 类EventsController < ApplicationController的 高清指数 @event = Event.new 结束
def create
@event = current_user.events.build(params[:event])
if @event.save
redirect_to root_path, :flash => { :success => "#{@event.inspect}!" }
else
@feed_items = []
render 'pages/home'
end
end
end
但是日期时间不落......我是什么我做错了?
我也希望能够插入小时和分钟。这只考虑了几天,几年和几个月。 – skline 2011-06-08 02:54:16
尝试更新回答:) – 2011-06-08 03:01:19