I am almost done with my RESTful application design.
Following are the nested resources:
map.resources :topics do |topics|
topics.resources :items do |items|
items.resources :attachments
end
end
A topic has a list of items and items may have attachments.
When a user accesses particular topic, he/she should also see
corresponding items and attachments. So a url topic_path(1), i.e.,
‘topic/1’ should also display related items and their attachments. This
is not a problem while rendering page in a html/rhtml format. I am using
_item and _attachment partials within topic/show.rhtml. How do I achieve
this in case of xml? The usual ‘format.xml {render :xml => @topic.to_xml}’ is of no use in this case.
Another way to access items and attachments would be:
‘topic/:id/items’ and ‘topic/:id/items/:id/attachments’.
This is pretty easy and rendering documents in different formats is not
a problem here. This also suggests ‘Resource = Record’ relationship. Any
thoughts on this?
One more thing I would like to add is downloading a topic in a zip file
format. Isn’t it just another formatted url ‘format.zip { render :file
=> @topic.generate_archive }’?
I am almost done with my RESTful application design.
Following are the nested resources:
map.resources :topics do |topics|
topics.resources :items do |items|
items.resources :attachments
end
end
A topic has a list of items and items may have attachments.
When a user accesses particular topic, he/she should also see
corresponding items and attachments. So a url topic_path(1), i.e.,
‘topic/1’ should also display related items and their attachments. This
is not a problem while rendering page in a html/rhtml format. I am using
_item and _attachment partials within topic/show.rhtml. How do I achieve
this in case of xml? The usual ‘format.xml {render :xml => @topic.to_xml}’ is of no use in this case.
Another way to access items and attachments would be:
‘topic/:id/items’ and ‘topic/:id/items/:id/attachments’.
This is pretty easy and rendering documents in different formats is not
a problem here. This also suggests ‘Resource = Record’ relationship. Any
thoughts on this?
One more thing I would like to add is downloading a topic in a zip file
format. Isn’t it just another formatted url ‘format.zip { render :file
=> @topic.generate_archive }’?
I am almost done with my RESTful application design.
Following are the nested resources:
map.resources :topics do |topics|
topics.resources :items do |items|
items.resources :attachments
end
end
A topic has a list of items and items may have attachments.
When a user accesses particular topic, he/she should also see
corresponding items and attachments. So a url topic_path(1), i.e.,
‘topic/1’ should also display related items and their attachments. This
is not a problem while rendering page in a html/rhtml format. I am using
_item and _attachment partials within topic/show.rhtml. How do I achieve
this in case of xml? The usual ‘format.xml {render :xml => @topic.to_xml}’ is of no use in this case.
Another way to access items and attachments would be:
‘topic/:id/items’ and ‘topic/:id/items/:id/attachments’.
This is pretty easy and rendering documents in different formats is not
a problem here. This also suggests ‘Resource = Record’ relationship. Any
thoughts on this?
One more thing I would like to add is downloading a topic in a zip file
format. Isn’t it just another formatted url ‘format.zip { render :file
=> @topic.generate_archive }’?
Thanks,
CS.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.