See Net::HTTP.

I would send you a link but ruby-doc.org is down

You do not need a model, in fact you probably shouldn't have one unless you 
want to store the data you receive somewhere. (even then you don't need a model)

You should think outside of the MVC box. Just because DHH put 3 folders named 
"models", "views", and "controllers" doesn't mean you have to put all of your 
ruby code there, especially if MVC doesn't fit your needs.


One specific scalability thing you might consider is that a in-request 
server-to-server API is generally considered non-scalable, but it depends on 
the response time on the remote API. If it is very fast maybe it will work. If 
it is slow, it will slow down your website.

If I'd were to build something really scalable, I'd fetch the external data in 
a background process and store it — database or otherwise — so that when the 
user looks at it it comes from cached place (may be a few minute stale). Then a 
background job runs on an as-needed basis to keep the data fresh. That's the 
scalable way to do it. 

But if scalability isn't a concern you can just make the API call, format the 
data the way you want it, and show it to the user. 

Your question was very high level and so was this answer. As a more 
specific/detailed question if you want a more specific/detailed answer. Your 
mileage may vary. 

-Jason

> On Jun 5, 2017, at 11:56 AM, Charlie Lor <[email protected]> wrote:
> 
> I'm very new to ruby on rails. I need a view that will show the data from a 
> JSON API calls. How do accomplish this? Do I need to create a model for this? 
> I assumed the controller is the place to put my API calls code, correct?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/98a65791-de22-4d63-ac39-a40d035cfdeb%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rubyonrails-talk/98a65791-de22-4d63-ac39-a40d035cfdeb%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

----

Jason Fleetwood-Boldt
[email protected]
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/805D4E44-E2D3-4CA4-A7EC-23F7C7FE5A94%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to