为了速度,我将从jbuilder迁移到Rabl,在我的站点上寻找一个搜索页面。这似乎是50%的速度,没有做任何其他优化,这是好的。
我有困难发送一个回形针URL通过拉布尔的观点,尽管。
原始Jbuilder视图:
json.array!(@venues) do |venue|
json.extract! venue, :id, :name, :longitude, :latitude, :price_range, :venue_category_id, :address, :short_description, :max_capacity
json.venue_images venue.venue_images do |vi|
json.url vi.image.url(:big)
json.urlthumb vi.image.url(:thumb)
json.id vi.id
end
end当前的Rabl观点:
object @venues
attributes :id, :name, :longitude, :latitude, :price_range, :venue_category_id, :address, :short_description, :max_capacity
child :venue_images do
attributes :id, :caption
child :image do
attributes :url
end
end这很好,我正在获取和显示图像,但是我希望能够在:url属性上使用Paper剪贴纸助手,但是如果我尝试:url(:拇指),Rabl会抛出一个语法错误。
有办法绕道吗?
谢谢
发布于 2014-08-12 12:03:08
基于Image url in JSON (RABL, Dragonfly, Ruby on Rails)
尝试:
child :venue_images do
attributes :id, :caption
node :image do |vi|
vi.image.url(:thumb)
end
end发布于 2014-08-12 11:56:54
我认为你必须在场地图像中添加一个节点。
如下所示:
child :venue_images do
attributes :id, :caption
node :url do |image|
o.image.url(:thumb)
end
endhttps://stackoverflow.com/questions/25263011
复制相似问题