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? Thanks, Zhongjie -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/g3a92vHCEQQJ. For more options, visit https://groups.google.com/groups/opt_out.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Lc-xHBFKtyEJ. For more options, visit https://groups.google.com/groups/opt_out.
Great. Thanks for pointing it out. On Tuesday, September 25, 2012 11:53:15 PM UTC-7, David Paschich wrote:> > > > 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 >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/CkhRFdUSnYUJ. For more options, visit https://groups.google.com/groups/opt_out.