What is the best practice for changing the functionality of a Rails controller, while keeping legacy code and the route intact? -


I have a web service that gives some XML data using some API data. I am going to implement a new database with a completely different control code, which will be effective after a certain date. But for any old data, any WS call should still use old DB.

Right now, the part of the URL contains the date I am parsing it at the beginning of the controller and then going to an old or new function.

  def web_service_action # Check code # some_instance_variables = # # between old and new methods Date and Fork are appropriate if use_new? Web_service_action_new other web_service_action_old end def use_new? Date_match = params [: id_string]. Milan (/ ^. * ([0-9] {8}) $ /) Matched_data = date_match [1] date = time.value (date_match [0,4], dated_mail [4, 2], date_match [6] , 2]) if date & gt; = DATE_CONSTANT return true and the end will return to end end   

I'm thinking that there is a clever way to do this in the next_filters or routes in a conditional file anyhow?

Additional information: I am using an old version of Rail (2.3.x) and the new method is a total rewrite, not an incremental change.

To start, I advise to look at Ryan Bates, they very well say that How to manage API changes in your application while maintaining BC.

Comments