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

  • SEARCH
  • Home
  • 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 8307385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:30:54+00:00 2026-06-08T18:30:54+00:00

I have a Rails app that acts as a pass-through for an XML services

  • 0

I have a Rails app that acts as a pass-through for an XML services API.

The main use cases goes like this:

  1. User POSTs parameters to Rails via http://example.com/model/report. For brevity, let’s say the form just submits zip_code=90010.
  2. Rails takes zip_code and uses RestClient to query an external XML services API via a GET request: http://xmlservice.example.com/report?report_id=1&zip_code=90010
  3. The report response is returned via XML. I want to parse the XML via Nokogiri and output a normal HTML view via report.html.erb.

I’m struggling to figure out where to put my XML (Nokogiri) code. Should I process the XML in my model or do all the parsing in the controller?

I know both methods will work, but I want to know what the best practice would be. This also is not a background XML feed grab, so it’s not suited to be a delayed job that runs nightly. It has to answer dynamic requests 24/7.

Keep in mind, I’ve removed ActiveRecord from my app for optimization. This app doesn’t touch any databases. It’s basically a pass-through to the XML API that will render HTML output for the client.

I’ve read it’s best to go with “skinny controllers” and “fat models”, but most of the Nokogiri examples I see out there have doc = Nokogiri::XML(RestClient.get(myurl, myparams)) type code inside the controller.

So… model or controller?

Thanks!

  • 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-08T18:30:55+00:00Added an answer on June 8, 2026 at 6:30 pm

    I would place the code in a class which would fetch the xml and parse the xml for you.

    This way its easier to Unit Test the class for parsing or any other operations you want to do on the returned XML.

    The class can be placed in the lib folder or if its sort of like a Pseudo Model ( with a XML Database ) it can be placed in Models as well. Thats mostly upto what the class is and how you would like structure your codebase.

    Update: a Plus of this approach, you code base can remain the same even if you swap out the service for something else, because you code base interacts with this class, the changes will have to be made only to this class. Interface advantages 🙂

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

Sidebar

Related Questions

I have a rails app that makes web api call , the rails app
I have a Rails app that repeatedly talks to another Web server through a
I have a rails app that I have serving up XML on an infrequent
I have a Rails app that was already setup to use devise with User
I have a Rails app that is served by Apache and Passenger, using only
I have a Rails app that does everything I need it to do via
I have a rails app that is using Devise perfectly in development. I have
I have a rails app that has asynchronous processing, and I'm having trouble getting
I have a Rails app that needs to expose values from a database as
I have a Rails app that archives high-res images (and thumbs) on S3 (via

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.