开发者

Archiving an Entire Rails Site

开发者 https://www.devze.com 2022-12-30 07:19 出处:网络
I have a Ruby on Rails site that was only needed for a short period of time during which users added various objects to a mySQL database, commenting on them, associating themselves with them, etc. etc

I have a Ruby on Rails site that was only needed for a short period of time during which users added various objects to a mySQL database, commenting on them, associating themselves with them, etc. etc. etc.

The question is this: the site is no longer needed until a week next year around this time when I will clear the database and use it again (starting from scratch). What's the best way to archive the current site so that the existing content is still viewable but 开发者_开发问答no new content can be added? By best way, I mean the method by which the least system resources will be used, the server will be the safest, etc.

Any suggestions?


If you wrote the app in the standard way, i.e. all the modifications are done via create, update or destroy actions in your controllers, add a before_filter to your ApplicationController that will prohibit accessing those methods (and probably new and edit, too).

You might also want to check your routes.rb to see if you don't have any other actions that modify your resources and add them to your filter too.


Use a web crawler and leave it as static html.


It depends how complicated are associations in your db. If it's very simple, you can write simple php site that only shows contents of your db (or maybe there is something that does it). It is cheapest solution (by mean of memory and cpu resources), but may need some work to achive.

If you don't want to work on your application, then possibly the fastest way (by mean of your time) is to use @szeryf approach. Just add in all routes :only => [:show, :index].


If the views are not common for editing and viewing the data, you could separate them with different controllers, one for just viewing, other for CRUD operations. Then it's matter of enabling and disabling the second one, possibly using routing.


Why not just remove create,insert and delete privileges from the database user?

0

精彩评论

暂无评论...
验证码 换一张
取 消