【发布时间】:2012-12-09 18:52:27
【问题描述】:
我有一个应用程序,用于为许多员工计划轮班。我有一个Shift 模型,我将shiftstart 和shiftend 存储为Time 对象。
我将用户Shifts 显示在一个表格中显示几天的页面上。这个想法是用户可以使用Best In Place gem 直接在此表中编辑shiftstart 和shiftend。
但在处理 Time 对象时,我似乎无法弄清楚如何让它工作 - 任何人都对此有一些经验或建议。
我有以下代码:
查看:
<% @myShifts.where(:shiftdate => date).order(:shiftstart).each do |shift| %>
<div class="shift-item span">
<div class="hider">
<p>
<i class="icon gear"></i>
<%= best_in_place shift.shiftstart.strftime("%H.%M"), :type => :input %> - <%= best_in_place shift.shiftend.strftime("%H.%M"), :type => :input %>
</p>
</div>
</div>
<% end %>
架构:
create_table "shifts", :force => true do |t|
t.time "shiftstart"
t.time "shiftend"
t.integer "type_id"
t.integer "user_id"
t.string "note"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.date "shiftdate"
end
我收到“undefined method `{:type=>:input}' for "08.00":String”错误,我已经尝试将 Best In Place Type 切换为其他类型输入 - 没有帮助..
【问题讨论】:
标签: ruby-on-rails time edit-in-place best-in-place