I'm kinda newbie in RoR yet and I'm having a hard time trying to figure
out how should I implement this. I'm writing an application to store and
display information about insects and their distribution. Currently I
have almost all functionality implemented, except for a **very**
important one: The application must be capable of "crawling" itself and
generate a zip archive for download. Actually, crawling itself isn't
accurate enough, since the views must be sightly different (e.g. don't
provide functionality not available without Internet connection,
indicate in the title that the page is an offline copy, etc).
The question is: Do you have any suggestions as to how I should
implement this?
One approach I had in mind (although I don't know how to program it),
would be calling from the controller that triggers the archive
generation, all the publicly accessible controllers and each of them
providing a non-routable method which uses the offline templates. This
method would be an index-like one except that it will repeatedly use the
offline view for #show, rendering to string and storing in a stream.
Another approach, let the zip generation controller access the views
from all the resources and iterate over all model data, making a really
centralized and big controller.
And lastly, make all public controllers check for "/static/" to tell
them to use the offline templates and then use some self crawling by
iterating over all model data. (For some reason, trying to self-crawl
didn't work for me in development even when using Thin which explicitly
advertises ">> Maximum connections set to 1024" when it boots up. The
problem would probably solve itself by using delayed job, though,
haven't tested yet.)
All the controllers dealing with resources were created with "rails g
scaffold ...".
In all the "solutions" above (except maybe in the third method) are
missing a procedure to include all assets in the zip archive properly
(i.e. enumerate them all and store them with the correct file name).
I'll be extremely grateful for any suggestions about how should I tackle
this problem!
--
Posted via
http://www.ruby-forum.com/.