Ember-rails generators dont work with rails 3.x engines #74

mankind opened this Issue Jul 9, 2012 · 9 comments

6 participants


When running 'rails g ember:boostrap' from within a rails 3.x engine, it produces the following error, which has been shortened to show what i believe is the main error, an inability to recognize the rails engine folder structure:

../lib/thor/actions/inject_into_file.rb:99: in 'binread': No such file or directory -/home/dav29/rails-dev/cal/calendar/app/assets/javascripts/application.js (Error:ENOENT)

I created a branch aimed at fixing this and i am opening this issue for discussion of the best approach. This ember-rails-generators-with-engines branch have been heavily modified to allow it run with rails 3.x engine, alas the generators still fails to run;


Please peep at the code and let's take it forward.


+1. As plugins are already deprecated, this is a must have feature for Gem developers wanting to package their code as a Rails Engine, which AFAIK is considered a best practice. @mankind, I'm pretty sure there's generator code that we could look at in Rails itself to get this working...


@clekstro yep, i believe it is an important feature. This are some code generators code we can look at

plataformatec/devise#1815. This was a pull request to fix decise generator on engine.

Also, looking at this Mongoid commit meant to handle Rails Engines when generating Mongodb indexes might be helpful;


We can look at the the two files below under the 'files changed ' tab from the link above

  lib/mongoid/railties/database.rake   &    lib/rails/mongoid.rb

For now, I have been creating all the code and directory structure for rails-engine by hand and to be honest it is not a problem, which was why I didn't push on with this.

With this one line, I can set up all the directories for emberjs in the rails-engine and then create the files as I go.

  mkdir   -p     app/assets/javascripts/{controllers,models,views,templates,routes}

We can join heads to see how to make it work within our limited free time.


I ran into this issue trying to use the bootstrap generator in a rails 3.x engine. The issue is that the generator is looking for app/assets/javascripts/application.js to add content to it. In a rails engine, for example named custom, that file will actually exist at app/assets/javascripts/custom/application.js instead. The generator has an option --ember_rails that you could use to pass in a custom path as in --ember_path=app/assets/javascripts/custom
but that did not work because it was looking for the file in the original location. I just submitted a pull request that should fix the issue.


If your engine is named custom_engine, use:

rails g ember:bootstrap --ember_path=app/assets/javascripts/custom_engine

At the moment, use the gem from github, until it's updated on rubygems.

Ember.js member

@jmflannery what can we do to improve this situation?


@stefanpenner it works as it is, but if you are working with a rails engine, it would probably be better if you didn't have to specify the --ember-path. I'll look into that.

Ember.js member

@jmflannery that would be fantastic.


@stefanpenner just sent a pull request that will make it so flags are not required when working in a rails engine


I have Rails 4 engine with ember-rails gem. But when I run rails g ember:bootstrap -g --javascript-engine coffee it shows me following errors:
Could not find generator ember:bootstrap.

Any idea?

@rwjblue rwjblue closed this Oct 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment