Image url in JSON (RABL, Dragonfly, Ruby on Rails)
问题 I'm using RABL gem, my user model has many posts users/show.rabl object @user attributes :id, :name child :posts do extends "posts/post" end posts/_post.rabl attributes :id, image: post.image.url I want to show post's image, but i have an error: undefined local variable or method "post" . But in posts/_post.html.erb i can use this <%= post.image.url =%> Images loaded by dragonfly gem. How can i get this image url in json format? 回答1: If this is a child-attribute you can append it back to the