我正在尝试使用 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 %>
在控制器中我这样做:class EventsController < ApplicationController def index @event = Event.new end
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
但是日期时间永远不会设置...我做错了什么?