1

I have the following setup in rails

class Book < AR
   has_one :assignment

class Assignment < AR
   belongs_to :book

My problem is that the assignment is an excluded model in a multi-tenant rails app while book is not. With apartment it is easy to do a has_one/belongs_to where the excluded model contains the has_one statement, but for various reasons I would like to store the foreign key in the Assignment model. Is there an easy way to do this?

Edit: the use case is a model that tracks reviews of the data in each book, which must be in one place for export to another application. The exported model must contain the id and tenant of the book being reviewed. Visiting each of hundreds of schemas on a cron job in order to collect the info is not a viable option. I am using postgres with a separate schema for each apartment.

sakurashinken
  • 3,940
  • 8
  • 34
  • 67
  • it seems odd to have the child record in the public schema pointing into the parent in the tenant specific schema. Could you elaborate on your use case? – srt32 Jul 17 '17 at 22:42
  • @srt32 I have edited the question with more details about the use case. – sakurashinken Jul 17 '17 at 22:51
  • Perhaps a stupid question but what happens when you set it up the way you have it in pseudo code? – srt32 Jul 18 '17 at 02:22

0 Answers0