Note that there are some explanatory texts on larger screens.

plurals
  1. PORails XML parsing -- should I put this functionality in the controller or model?
    primarykey
    data
    text
    <p>I have a Rails app that acts as a pass-through for an XML services API.</p> <p>The main use cases goes like this:</p> <ol> <li>User POSTs parameters to Rails via <a href="http://example.com/model/report" rel="nofollow">http://example.com/model/report</a>. For brevity, let's say the form just submits <code>zip_code=90010</code>.</li> <li>Rails takes <code>zip_code</code> and uses RestClient to query an external XML services API via a GET request: <a href="http://xmlservice.example.com/report?report_id=1&amp;zip_code=90010" rel="nofollow">http://xmlservice.example.com/report?report_id=1&amp;zip_code=90010</a></li> <li>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.</li> </ol> <p>I'm struggling to figure out where to put my XML (Nokogiri) code. Should I process the XML in my <em>model</em> or do all the parsing in the <em>controller</em>?</p> <p>I know both methods will work, but I want to know what the best practice would be. This also is <em>not</em> 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.</p> <p>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.</p> <p>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 <code>doc = Nokogiri::XML(RestClient.get(myurl, myparams))</code> type code inside the controller.</p> <p>So... model or controller? </p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload