2012-12-22 8 views
2

나는 많은 직원의 근무 교대를 계획하는 데 사용되는 앱을 가지고 있습니다. 나는 과 shiftendTime 개체로 저장하는 Shift 모델을 가지고 있습니다.시간 개체의 편집 위치에서

테이블에 며칠 표시되는 페이지에 Shifts 사용자를 표시합니다. 사용자는 Best In Place 보석을 사용하여이 표에서 shiftstartshiftend을 직접 편집 할 수 있습니다.

하지만 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 %> 

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 

나는 "정의되지 않은 메서드를 받고 있어요`{: 유형 => : 입력} 'for "08.00": String "오류가 발생했습니다. 다른 유형의 입력에 가장 적합한 입력 유형을 전환 해 보았습니다.

답변

4

best_in_place 메서드는 두 가지 필수 인수를 취합니다. 개체 (shift) 및 필드 (shiftstartshiftend), 옵션의 해시 (:type => :input). 그래서 코드는 다음과 같이 할 필요가 :

나에게 오류 제공
<%= best_in_place shift, :shiftstart, :type => :input, :display_with => Proc.new { |f| f.strftime("%H.%M") } %> 
+0

: #에 대한 정의되지 않은 메서드'shift_path을 '<# <클래스 : 0x007fe659934800> : 0x007fe653ce4460> .. 어떤 아이디어? – Twiddr

+0

아마도 시프트의 액션을 처리하기 위해'ShiftsController'를 사용하지 않았을 것입니다. 'PATH 요청을 처리하는 실제 시프트 경로를': path => your_shift_path (shift)'와 같은'best_in_place' 옵션에 제공 할 수 있습니다. 아니면 더 많은 통찰력을 얻기 위해'레이크 루트 (rake routes) '를 제공 할 수 있습니다. –

+0

문제가 발견되었습니다 .. 내 경로가 맞지 않았습니다 ..하지만 솔루션이 제대로 작동하는 것 같습니다. :) – Twiddr