Where do i put the code to pull data from an API?

My app doesnt use a database, it gets all it’s information from an
api. I was wondering whether i should put the code for pulling the api
data into an array in the controller or a model?

This is a pretty simple app right now with only one controller, I may
expand it later but I have no plans to do so right now.

Koalemos wrote:

My app doesnt use a database, it gets all it’s information from an
api. I was wondering whether i should put the code for pulling the api
data into an array in the controller or a model?

This is a pretty simple app right now with only one controller, I may
expand it later but I have no plans to do so right now.

I’m curious what others say. I’m going to be in the same boat in a few
days. But it sounds like a model to me. The API to fetch the data is
logically the same as the API to the database methods to fetch the data.

Thats my thought anyway.

In the model,
All your data objects should be in the models, and the controller is
simply a bridge between the models and the views, pooling out only the
data the view needs, so you’d write methods for retrieving and
creating data in your model and then call those functions in your
controllers and parse those arrays etc into your views.

Cam

Definitely in a model. Here’s the Rails hint: ActiveResource::Base
(edge/2.0) is similar to ActiveRecord::Base.