Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8222439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:16:56+00:00 2026-06-07T14:16:56+00:00

I have a web service that returns some XML data using a RESTful API.

  • 0

I have a web service that returns some XML data using a RESTful API. I am going to implement a new database with completely different controller code, that will be in effect after some date. But any WS call for the old data should still use the old DB.

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

def web_service_action

  #shared code between old and new methods
  @some_instance_variables = ...

  # check the date and fork appropriately
  if use_new?
    web_service_action_new
  else
    web_service_action_old
  end

  def use_new?
    date_match = params[:id_string].match(/^.*([0-9]{8})$/)
    matched_date = date_match[1]
    date = Time.local(date_match[0,4],date_match[4,2],date_match[6,2])
    if date >= DATE_CONSTANT
      return true
    else
      return false
    end  
  end

end

I’m wondering if there is a clever way to do this with a before_filter or a conditional in the routes file somehow?

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:16:57+00:00Added an answer on June 7, 2026 at 2:16 pm

    To start, I recommend watching Ryan Bates’ railscast on REST API Versioning. He explains very well how to manage API changes in your application while maintaining BC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a third party web service that returns this xml <book> <release_date>0000-00-00</release_date> </book>
I have web service written that generates some data...can I call the web service
I have access to an web service that returns an XML or JSON. Since
I have a SOAP web service that returns an XML in this format <SOAP-ENV:Envelope
I am using Cherrypy in a RESTful web service and server returns XML as
I am using WCF Web API service to publish some data via Json and
i call a web service that returns some HTML which enclosed in an XML
I have a web service that returns the binary array of an object. Is
I'm dealing with times formats in Restkit, I have a web service that returns
I have a WSE web service that returns a list of items in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.