我試圖按照薩斯 - > CSS轉換器代碼Sass website。File.load和File.read之間的區別紅寶石
template = File.load('stylesheets/sassy.sass')
sass_engine = Sass::Engine.new(template)
output = sass_engine.render
puts output
我得到這個錯誤,而我試圖File.load
SyntaxError in PublishController#index
/Users/jkim/rails/support-rhapsody/app/assets/stylesheets/application.sass:1: target of repeat operator is not specified: /* http:/
/Users/jkim/rails/support-rhapsody/app/assets/stylesheets/application.sass:2: no .<digit> floating literal anymore; put 0 before dot
v2.0 | 20110126
^
/Users/jkim/rails/support-rhapsody/app/assets/stylesheets/application.sass:2: syntax error, unexpected tINTEGER
v2.0 | 20110126
^
/Users/jkim/rails/support-rhapsody/app/assets/stylesheets/application.sass:3: syntax error, unexpected ':', expecting $end
License: none (public domain) */
但是當我做File.read,它正常工作,直到output = sass_engine.render
。
我得到這個錯誤,
NoMethodError in PublishController#index
undefined method `[]' for nil:NilClass
什麼File.read和File.load之間的區別?如果你知道如何在Sass中解決這個問題,那就更好了。
你試過'ri File.load'和'ri File.read'嗎?這兩種方法的用途非常不同。 –
'ri File.load'獲取'NoMethodError:調用File:Class'的私有方法'load'。和 'ri File.read'得到'ArgumentError:錯誤的參數數量(0代表1..4)' –
你不應該在IRB提示符中輸入'ri'。它是一個單獨的shell命令,可爲您提供rdoc信息。 –