可能是相当基本的东西,但我希望能够在模块化Sinatra应用程序中使用一些自定义帮助程序方法。我在./helpers/aws_helper.rb以下NoMethodError Sinatra模块化应用程序
helpers do
def aws_asset(path)
File.join settings.asset_host, path
end
end
,然后在我看来,我希望能够用这种方法,像这样
<%= image_tag(aws_asset('/assets/images/wd.png')) %>
,但我得到上面的面积,从而在我的app.rb文件我
require './helpers/aws_helper'
class Profile < Sinatra::Base
get '/' do
erb :index
end
end
所以是我的问题,我要求它在我的配置文件类之外。这是没有意义的,因为我需要我的配置文件的ENV变量相同的方式,他们正在阅读,但他们又不是方法,所以我想这是有道理的。
我想也许我正在努力让自己的头脑模糊一下模块化应用程序,而不是使用经典风格的sinatra应用程序。
任何指针赞赏
错误消息
NoMethodError at/undefined method `aws_asset' for #<Profile:0x007f1e6c4905c0> file: index.erb location: block in singletonclass line: 8
你真的错过你'require'行的结尾撇号?什么是你收到的实际的完整错误信息? – Casper
不,这是一个错字,已经修改,我也添加了我得到的错误 – Richlewis