我想使用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