4

I want to create a parent application that deals with the User Authentication. I then want to create various Mountable Engines (like a blog, contact directory, etc.) that can be added as needed. This means that I will need to access the User Authentication data (admin rights, etc.) from the Mountable Engine.

I would like to know how (and if) this is possible, as it is evident that the Engine Models are accessible in the parent application it is integrated in to, but not the other way round.

When this question was asked here, the answer given shows how to get all data, not things from helpers (like current_user).

When it was asked here, it seemed to cover namespacing, not the how to access functions and variables (unless I'm missing something).

Any help would be greatly appreciated.

Community
  • 1
  • 1
Theo Scholiadis
  • 2,316
  • 2
  • 22
  • 33

1 Answers1

1

By design, Mountable Engines are isolated from their parent. However, you can in theory expose portions of the parent through a REST API using ActiveResource or the like. You can also use a 'Full Engine' which acts as a sort of plugin rather than a Mountable one - Rails 3.1: Engine vs. Mountable App

Community
  • 1
  • 1
PinnyM
  • 35,165
  • 3
  • 73
  • 81
  • I've read those articles, and did so again after your answer. You're right in that it seems that things are more "exposed" in the "Full Engine", and granted, my engines are not independent apps. But is it not more intuitive to have them namespaced separately with their own javascripts and CSS files and considered independent? – Theo Scholiadis Apr 04 '12 at 09:47
  • 1
    Perhaps, but that seems to be a matter of opinion. You can accomplish a similar thing using the 'Full Engine' approach with namespaced routes and add hooks to copy over migrations and assets (JS, CSS, images) from the engine to the parent directory as part of a rake/capistrano task before deploy. The popular 'spree' gem does this and it works fairly well for me. – PinnyM Apr 04 '12 at 14:59