I'm writing a simple page that will help me view the sync status of my sites custom gallery compared to my Flickr account.
I have a simple loop that iterates over a response from the Flickr API:
<% for collection in @flickr_hierarchy %>
<%= traverse_collection(collection, 0) %>
<% end %>
traverse_collection
is a Rails helper method as so:
module GalleryHelper
def traverse_collection(collection, parent)
parent = parent == 0 ? 0 : parent["id"]
content_tag(:tr) do
content_tag(:td, 'Collection')
collectionLocal = Collection.where(flickr_id: collection.id).first
if collectionLocal != nil
content_tag(:td, 'Yes')
else
content_tag(:td, 'No')
end
content_tag(:td, ' ')
content_tag(:td, ' ')
content_tag(:td, collection.title)
content_tag(:td, collection.id)
content_tag(:td, parent.to_s)
content_tag(:td, 'N/A')
content_tag(:td) do
if collectionLocal != nil
button_to('Add all Sets', admin_add_all_sets_for_collection_path(flickr_collection_id: collection.id))
button_to('Delete Collection', admin_delete_collection_path(flickr_collection_id: collection.id))
else
button_to('Add Collection', admin_add_collection_path(flickr_collection_id: collection.id, flickr_parent_collection_id: parent.to_s))
button_to('Add Collection and Sets', admin_add_all_sets_for_collection_path(flickr_collection_id: collection.id, flickr_parent_collection_id: parent.to_s))
end
end
end
end
end
Unfortunately i've found out that there is no nice or non-messy code way to get the generated HTML to be output on my page.
Is there a good way to do this or should I be taking a different approach. Any ideas?
Thanks, Neil