1

I have a rails model where some part of data comes from database and other by calling a restful web service. Is there a way to use both ActiveRecord and ActiveResource in the same model to achieve this?

Ideally I would like to load the attributes that it gets from web service lazily (when accessed in controller) and only load the db attributes by default. Is it best if I create two models one that accesses service using ActiveResource and one with ActiveResource which :has_one of the active resource model. Also, how to make sure I only call the service when only activeresource methods are accessed (like a before_filter but for only those methods - if I have a relationship with other model, doesn't rails already do that)?

Thanks in advance.

Sainath Mallidi
  • 515
  • 1
  • 7
  • 17

1 Answers1

0

Have a look at the delegate method... This way you can proxy methods to another model.

http://blog.wyeworks.com/2009/6/4/rails-delegate-method

hurikhan77
  • 5,881
  • 3
  • 32
  • 47