开发者

How to remove some functionality from a Rails application

I have a rails application in which I implemented some feature. Now I want to remove that feature without breaking the code. Since the a开发者_如何学编程pplication is running on the production server, this makes it a little bit critical. How do I do the following.

  • remove all the tables from the database concerned with this functionality?
  • remove the controllers, models and view files?
  • correct the other controllers and views which are related with this functionality?

The first one can be achieved by generating migrations which produce reverse result to that of which try to create the tables related to this functionality. How should I proceed towards the code removal? I am using git as my source code manager.


Create some migrations to remove the now useless databases/fields

Remove the controllers, models and view files

Correct anything that's now broken (I hope you're writing tests)

Push your code to your staging server and check everything is properly working

When everything is ok, push your code to production. And you should roll.


Use git to create a separate branch (I'll call it "less"), and make all the changes on that branch. That way your site keeps running. You should have another copy of your application running somewhere (ie, on your local computer) that is running from the "less" branch.

It's vital that you have tests in order to ensure that removing features doesn't break something else unintentionally. Run your tests on the test server (running off the "less" branch).

Once your test server performs properly and your tests run okay, merge your "less" branch into your "master" branch (that your production server is running off of). Pull the changes to your production server, restart, and you're good to go.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜