2
我有一个应用程序,用于为多个员工计划工作班次。我有一个Shift
模型,在那里我存储shiftstart
和shiftend
作为Time
对象。对时间对象进行编辑
我在一个表格中显示几天的页面上显示用户Shifts
。这个想法是,用户可以使用Best In Place宝石直接在该表中编辑shiftstart
和shiftend
。
但是我似乎无法弄清楚如何在处理Time对象时得到这个工作 - 任何人都可以在这方面获得一些经验或建议。
我有以下代码:
VIEW:
<% @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 %>
SCHEMA:
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
我得到一个“未定义的方法`{:类型=>:输入} '为“08.00”:字符串“错误,我已经尝试切换到最好的地方类型输入的东西 - 没有帮助..
这给了我一个错误:未定义的方法'shift_path”为#<#<类别:0x007fe659934800>:0x007fe653ce4460> ..任何想法? – Twiddr
也许你没有使用'ShiftsController'来处理轮班的动作。您可以将您的实际移位路径(处理PUT请求的路径)提供给''best_in_place''选项,如下所示::path => your_shift_path(shift)'。或者你可以提供你的'rake routes'以获得更多的见解:)。 –
发现问题..我的路线不正确..但你的解决方案似乎工作..只是完美.. :) – Twiddr