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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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.

Search Discussions

  • David Paschich at Sep 26, 2012 at 6:53 am

    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    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.
  • Zhongjie Wu at Sep 27, 2012 at 9:38 pm
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedSep 25, '12 at 3:22p
activeSep 27, '12 at 9:38p
posts3
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Zhongjie Wu: 2 posts David Paschich: 1 post

People

Translate

site design / logo © 2022 Grokbase