Skip to content

Instantly share code, notes, and snippets.

@FerPerales
Last active July 21, 2016 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FerPerales/443530189c0d7bb0171698b7725995a9 to your computer and use it in GitHub Desktop.
Save FerPerales/443530189c0d7bb0171698b7725995a9 to your computer and use it in GitHub Desktop.
ActiveResource vs. ActiveRecord
Al contrario: la sintaxis es similar:
En ActiveRecord, Person.find(1) buscara en la base de datos local una tabla llamada `people` y buscará el registro con el
id 1, traerá la informacion y la podras utilizar mediante un objeto de Ruby
En ActiveResource, Person.find(1) hará una llamada HTTP a la API que le hallas configurado en `self.site` infiriendo la ruta
a la que debe llamar siguiendo la arquitectura REST. Si tu `self.site` es, por ejemplo, http://api.demosite.com,
ActiveResource hará una petición GET a la ruta http://api.demosite.com/people/1, traerá la informacion y la podras utilizar
mediante un objeto de Ruby
De una manera resumida, usa ActiveRecord cuando tu info esté en tu base de datos local. Usa ActiveResource cuando la info
esté disponible mediante una API REST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment