Shopify/batman — Issue #346: rails mountable engines not supported
Author: luxerama
Created: 2012-02-29 12:05:58+00:00
State: open

When I use batman-rails in a mountable rails engine I'm running into difficulties with isolate_namespace.
```
rails g batman:install
.../gems/batman-rails-0.0.4/lib/generators/batman/common.rb:11:in `with_app_name': Batman application name must be given (RuntimeError)
from .../gems/batman-rails-0.0.4/lib/generators/batman/install_generator.rb:15:in `create_batman_app'
from .../gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from .../gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from .../gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
from .../gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
from .../gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
from .../gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
from .../gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
from .../gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
from .../gems/railties-3.2.1/lib/rails/generators.rb:170:in `invoke'
from .../gems/railties-3.2.1/lib/rails/commands/generate.rb:12:in `'
from .../lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from .../lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from .../gems/railties-3.2.1/lib/rails/engine/commands.rb:21:in `'
from .../lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from .../lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from script/rails:8:in `

'
```
When I use ```rails g batman:install --app-name=``` it works if I make some changes to the static path in .../gems/batman-rails-0.0.4/lib/generators/batman/common.rb
```
29 def js_path
30 "app/assets/javascripts/"
31 end
```
That way the generated files are put in the correct location. However this only delays the inevitable because when I load my controllers in my app its not going to find them where it expects them to be

```
window.Ems = class Ems extends Batman.App
@controller 'articles'
.....
```
When batman tries to load the controller with XHR:

```
GET http://dev4.beans:3000/ems/controllers/articles_controller.coffee 404 (Not Found)
```

I tried to set the ```requirePath```

```
window.Ems = class Ems extends Batman.App
@requirePath = '/assets/ems/'
@controller 'articles'
.....
```

But this means that it will try to locate all (like CoffeeScript) dependencies in that location.

```
Uncaught ReferenceError: CoffeeScript is not defined
Batman.App.developer.do.App.require.Batman.Request.successbatman.js:2464
__bindbatman.js:15
Batman.Event.Event.firebatman.js:629
Batman.SimpleSet.SimpleSet.forEachbatman.js:1770
Batman.SimpleHash.SimpleHash.forEachbatman.js:1525
Batman.SimpleHash.SimpleHash.forEachbatman.js:1528
Batman.SimpleSet.SimpleSet.forEachbatman.js:1769
Batman.Event.Event.eachHandlerbatman.js:581
Batman.Event.Event.firebatman.js:628
Batman.EventEmitter.firebatman.js:686
Batman.Request.send.options.successbatman.jquery.js:18
__bindbatman.jquery.js:2
jQuery.Callbacks.firejquery.js:1047
jQuery.Callbacks.self.fireWithjquery.js:1165
donejquery.js:7400
jQuery.ajaxTransport.send.callback
```