Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify config if I am using templates inside a mountable engine (namespace isolated) #140

Open
neilhanekom opened this issue Jul 8, 2016 · 3 comments

Comments

@neilhanekom
Copy link

How would I go about specifying my config paths if I am using templates inside a rails mountable engine.

@pitr
Copy link
Owner

pitr commented Jul 8, 2016

You can try specifying configs in yours engine's config file. Frankly I have never tried this, so if you get it working please let everyone know here.

@neilhanekom
Copy link
Author

The simplest way I got it to pick up the templates in my mounted engine was to add my engine's template path to the array of the inside_paths config in my main application's (config/application.rb) file.

in my case my engine is mounted in vendor/engines directory as per rails guides documentation.
my engine name "sukumafin"..... so I added it like in the line below.

config.angular_templates.inside_paths = ['app/assets', 'vendor/engines/sukumafin/assets/']

I guess the catch here is to be cautious when naming your templates so there is no clashes between the app's templates and your engine template names. ...???

My observation here is that engines are simply another railtie added to main application and somehow uses one asset pipeline for js/css. So take due diligence when using angular with engines inside applications that uses angular and angular rails templates. Maybe slightly off the topic but I could not make ui.router work in the setup I have now and had to use "angular-routes" and I also had to ensure that there should are no routes clashing as well.

@voltechs
Copy link

What worked for me was putting the templates/ directory directly under javascripts/ (not javascripts/engine_name/. Be sure to maintain the namespacing, however. So your final directory structure should be as follows (and this is a frustrating redundancy of Rails)

  • engine_name (root)
    • app
      • assets
        • javascripts
          • engine_name
            • ... your js files
          • templates
            • engine_name
              • ... your template files

And everything basically works as expected. Be sure to call your template files with the proper name-spacing (engine_name) in front.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants