Re: Model using external data source?

23 views
Skip to first unread message

David Paschich

unread,
Sep 26, 2012, 2:53:15 AM9/26/12
to rubyonra...@googlegroups.com


On Tuesday, September 25, 2012 1:08:46 AM UTC-7, Zhongjie Wu wrote:
Hi, I am writing a management system and one of the datasource is external(read-only) and I need to use REST API to access them. Can I just reuse the Model part of MVC but override those database access methods to do REST calls instead?

Absolutely. The objects in your model don't have to inherit from ActiveRecord or any other part of Rails if you don't need them to. Just write up an object to wrap the API calls. 

Rails used to have a module called ActiveResource for this, but it seems nobody liked it enough to keep it working, so it was dropped. In my current project, I just have to read from the REST API, and https://github.com/archiloque/rest-client is working well so far.

-David 

Zhongjie Wu

unread,
Sep 27, 2012, 5:38:37 PM9/27/12
to rubyonra...@googlegroups.com
Great. Thanks for pointing it out.
Reply all
Reply to author
Forward
0 new messages