10

I have a Rails Engine and I want to access the parents models. Is that possible? If so, how would I do it?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Shamoon
  • 41,293
  • 91
  • 306
  • 570
  • What do you mean by "access"? The engine and Rails application run in the same thread of the same interpreter instance, so you can, for instance, access any class available through Ruby. Are you looking for an API to do so? – coreyward Jan 17 '12 at 02:40
  • Sorry... I have an engine and it's mounted in a Rails application. The Rails application has certain models (Let's say.. `User` as an example). I need the engine to read/write data from that model. – Shamoon Jan 17 '12 at 17:56

1 Answers1

18

I didn't find any official documentation about it, but here's how you could still do it:

tests = ::Test.all

It'll return all tests from the parent app Test model.

jipiboily
  • 1,240
  • 10
  • 17