【发布时间】:2013-04-06 15:10:37
【问题描述】:
images.js.coffee.erb 文件:
<%
imgs = {}
Dir.chdir("#{Rails.root}/app/assets/images/bg/") do
imgs = Dir["**"].inject({}) {|h,f| h.merge! f => image-url(f)}
end
%>
window.image_path = (name) ->
<%= imgs.to_json %>[name]
page.js.coffee 文件:(获取图片路径)
icon=image_path("myfile.jpb")
错误:
undefined local variable or method `image' for #<#<Class:0x007ffdaac7cd88> on line 4
4 imgs = Dir["**"].inject({}) {|h,f| h.merge! f => image-url(f)}
问题是我的 image-url() 方法似乎不起作用。为什么 image_path() 有效,而 image-url 无效?
谢谢
【问题讨论】:
-
你的意思是
image_url可能吗?
标签: ruby-on-rails coffeescript sass