angular-rails-templates
angular-rails-templates copied to clipboard
How to specify config if I am using templates inside a mountable engine (namespace isolated)
How would I go about specifying my config paths if I am using templates inside a rails mountable engine.
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.
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.
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
- engine_name
- engine_name
- javascripts
- assets
- app
And everything basically works as expected. Be sure to call your template files with the proper name-spacing (engine_name) in front.