3
一直有一個問題,導軌/黃瓜/火腿。下面Haml的文件完全在發展和生活環境,但未能在黃瓜以下錯誤:
/app/views/competitions/show.haml:30: syntax error, unexpected kENSURE, expecting $end (ActionView::TemplateError)
On line #30 of app/views/competitions/show.haml
線#30是文件的末尾。它工作在Haml的寶石2.2.3版本,但不是在後來的(我試過2.2.23,2.2.22,2.2.17)
- title @competition.name
%h1
=h @competition.name
- if @competition.image?
#main_image
= image_tag(@competition.image_url)
= RedCloth.new(@competition.description).to_html
%h2
=h @competition.question
%p
- if @competition.running?
= link_to 'Enter competition', enter_path(:id => @competition.secret)
- else
= case @competition.state
- when 'scheduled' then 'Competition has not opened'
- when 'closed' then 'Competition closed'
if can? :update, @competition
= link_to 'Edit', edit_competition_path(@competition)
|
- if can? :show_stats, @competition
= link_to 'View stats', competition_stats_path(@competition)
任何想法發生了什麼?
很難說沒有在我面前的實際代碼發生了什麼。嘗試暫時刪除一個代碼塊,然後查看其效果。開始縮小範圍。例如,嘗試刪除包含'%p'塊的所有內容,然後重新運行測試。 – 2010-04-21 23:19:33
24號線上,你的意思是逃避嗎? :更新,@競爭'被解釋爲紅寶石代碼前面用連字符? ' - 如果可以? :更新,@競爭'。 – 2011-03-23 01:12:46
有沒有機會在這個HAML文件被調用之前有'ensure..end'異常處理塊?在我看來,'ensure'在沒有適當的'end'的情況下被調用,並且HAML文件恰好在錯誤的時間出現在錯誤的地方。錯誤可能與此文件無關。 – 2011-05-27 02:42:14