Ruby on rails 3.2 JSON格式的图像url(RABL、蜻蜓、RubyonRails)
我正在使用rablgem,我的用户模型有很多帖子 用户/show.rablRuby on rails 3.2 JSON格式的图像url(RABL、蜻蜓、RubyonRails),ruby-on-rails-3.2,rabl,dragonfly-gem,Ruby On Rails 3.2,Rabl,Dragonfly Gem,我正在使用rablgem,我的用户模型有很多帖子 用户/show.rabl object @user attributes :id, :name child :posts do extends "posts/post" end attributes :id, image: post.image.url posts/\u post.rabl object @user attributes :id, :name child :posts
object @user
attributes :id, :name
child :posts do
extends "posts/post"
end
attributes :id, image: post.image.url
posts/\u post.rabl
object @user
attributes :id, :name
child :posts do
extends "posts/post"
end
attributes :id, image: post.image.url
我想显示post的图像,但我有一个错误:未定义的局部变量或方法“post”
但是在posts/_post.html.erb中,我可以使用这个
由蜻蜓宝石加载的图像
如何以json格式获取此图像url?如果这是一个子属性,则可以使用胶水将其追加回根节点 像这样:
@post
attributes :id, :image_url
glue @image do
attributes :url => :image_url
end
或者像这样:
@post
attributes :id
node :image_url do |post|
post.image.url
end