0
我想从我的rabl
模板调用Rails辅助方法。我能够为它的一个对象via Stack Overflow。调用Rails集合中的Rails帮助器
这是我的当前设置(和它的正常工作)
我有一个帮手
#app/helpers/application_helper.rb
module ApplicationHelper
def full_url(image)
"#{request.protocol}#{request.host_with_port}#{image.picture_url}" if recipe.image
end
end
#app/images/show.rabl
object @image
attributes :id, :picture_url
node(:picture_url) { full_url(@image) }
现在我要为图像对象的列表做到这一点,但它不工作,我不能在rabl
自述文件中找到它。
问题是,它传递@images
名单,我不知道如何调用一个辅助方法的各个对象上
#app/images/index.rabl
collection @images
attributes :id,
node(:picture_url) { full_url(@images) }
什么是'full_url'?它应该是'thumb_url'吗? – BroiSatse 2014-09-26 11:14:40
@BroiSatse,对不起..我的坏,它应该是'full_url',我正在简化我的代码,并得到一个错字。我更新了我的问题。 – sameera207 2014-09-26 11:32:27