extending activeRecord with activeResource

21 views
Skip to first unread message

Zdravko Balorda

unread,
Mar 3, 2016, 3:25:57 PM3/3/16
to rubyonra...@googlegroups.com
How to extend ActiveRecord from database with additional columns from
ActiveResource?
I have an ActiveRecord class Person which I need to extend with columns
from remote database which I can access with ActiveResource class Party.
Can Party be seemlessly integrated into Person?
Regards, Zdravko

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Mar 3, 2016, 3:50:18 PM3/3/16
to Ruby on Rails: Talk
On 3 March 2016 at 20:25, Zdravko Balorda <li...@ruby-forum.com> wrote:
> How to extend ActiveRecord from database with additional columns from
> ActiveResource?
> I have an ActiveRecord class Person which I need to extend with columns
> from remote database which I can access with ActiveResource class Party.
> Can Party be seemlessly integrated into Person?

There may be other ways, but unless someone provides a better solution
I would setup a has_one belongs_to relationship between them, and then
if you really want to avoid having to do @person.party.field then
define accessor methods in Person so that @person.field references
self.party.field

Colin

> Regards, Zdravko
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/049afd0291e817ad42d87dd720ffd0a0%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages