Skip to content

Instantly share code, notes, and snippets.

@vinniefranco
Created January 25, 2011 22:48
Show Gist options
  • Save vinniefranco/795870 to your computer and use it in GitHub Desktop.
Save vinniefranco/795870 to your computer and use it in GitHub Desktop.
json.gallery do |g|
g.info do |info|
info.title @gallery.title if @gallery.title
info.image @gallery.image.l(:medium) if @gallery.image
info.parent_id @gallery.parent_id if @gallery.parent_id
info.root true unless @gallery.parent_id
end
@gallery.photos.each do |photo|
g.photos do |p|
p.id photo.id
p.title photo.title
p.description photo.description
p.image photo.image.l(:medium) if photo.image
end
end
@gallery.galleries.each do |gallery|
g.galleries do |gg|
gg.id gallery.id
gg.title gallery.title
gg.meta "#{pluralize(gallery.galleries.count, 'Gallery') if gallery.galleries.any?} #{pluralize(gallery.photos.count, 'Photo') if gallery.photos.any?}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment