我正在編寫一個Rails應用程序。Coffeescript訪問current_user
在CoffeeScript中,我想訪問current_user以及它與員工的關係。
這是我想要的代碼:
$.create "/events/",
event:
title: title,
starts_at: "" + start,
ends_at: "" + end,
all_day: allDay,
hours: hours,
employee_id: current_user.employee_id
# pickup the current employee
但是,控制檯顯示 - 未捕獲的ReferenceError:提前爲幫助CURRENT_USER沒有定義
謝謝!
剛會工作。但是,在觀看railscast時,我發現我可以使用<%= content_tag「div」,id:「calendar」,data:{employeeid:current_user.employee.id} do%> – Reddirt
我相信'data'僅適用於HTML5。 –