rails 3.1rc4, Engine rather broken

Hi there.

I'm having some real issues with engines and rc4:

1: generators are broke

rails plugin new myengine --mounable
cd myengine
rails g

2: after you build an engine and gem it up, if you do:

rails new myproject
add gem 'myengine' to Gemfile
add mount MyEngine::Engine => '/myengine'
rake routes:

myengine /myengine {:to=>MyEngine::Engine}

then rails s

visit http://localhost:3000/myengine

error log:

Started GET "/myengine" for at Thu Jul 07 16:07:11 +0100
ActionController::RoutingError (No route matches [GET] "/myengine"):

This is really odd, as rails 3.0 engines worked just fine on rails3.0,
however my namedspaced rails3.1 engine wont (and cant run on 3.0 as
isolate namespace is 3.1 only)

What can I do. Currently setting to edge-rails gets bundle failures
on actionpack (3.2.0.beta) etc...


Perhaps the issue is related to passing “mounable” instead of “mountable”:

rails plugin new myengine --mountable

Allen Madsen


Can you please confirm and fill this issues in a bug report?.
With the latest edge code I don't get that ...

➜ /tmp ruby ~/WyeWorks/Projs/rails/bin/rails new myengine --mountable --dev
      create README
      create Rakefile
      create config.ru
      create .gitignore
      create Gemfile
      create app
      create app/assets/images/rails.png
      create app/assets/javascripts/application.js
      create app/assets/stylesheets/application.css
      create app/controllers/application_controller.rb
      create app/helpers/application_helper.rb
      create app/mailers
      create app/models
      create app/views/layouts/application.html.erb
      create app/mailers/.gitkeep
      create app/models/.gitkeep
      create config
      create config/routes.rb
      create config/application.rb
      create config/environment.rb
      create config/environments
      create config/environments/development.rb
      create config/environments/production.rb
      create config/environments/test.rb
      create config/initializers
      create config/initializers/backtrace_silencers.rb
      create config/initializers/inflections.rb
      create config/initializers/mime_types.rb
      create config/initializers/secret_token.rb
      create config/initializers/session_store.rb
      create config/initializers/wrap_parameters.rb
      create config/locales
      create config/locales/en.yml
      create config/boot.rb
      create config/database.yml
      create db
      create db/seeds.rb
      create doc
      create doc/README_FOR_APP
      create lib
      create lib/tasks
      create lib/tasks/.gitkeep
      create lib/assets
      create lib/assets/.gitkeep
      create log
      create log/.gitkeep
      create public
      create public/404.html
      create public/422.html
      create public/500.html
      create public/favicon.ico
      create public/index.html
      create public/robots.txt
      create script
      create script/rails
      create test/fixtures
      create test/fixtures/.gitkeep
      create test/functional
      create test/functional/.gitkeep
      create test/integration
      create test/integration/.gitkeep
      create test/unit
      create test/unit/.gitkeep
      create test/performance/browsing_test.rb
      create test/test_helper.rb
      create tmp/cache
      create tmp/cache/.gitkeep
      create vendor/assets/stylesheets
      create vendor/assets/stylesheets/.gitkeep
      create vendor/plugins
      create vendor/plugins/.gitkeep
         run bundle install
Updating git://github.com/rails/sass-rails
Updating git://github.com/rails/coffee-rails
Fetching source index for http://rubygems.org/
Using rake (0.9.2)
Using i18n (0.6.0)
Using multi_json (1.0.3)
Using activesupport (3.2.0.beta) from source at
Using bcrypt-ruby (2.1.4)
Using builder (3.0.0)
Using activemodel (3.2.0.beta) from source at
Using erubis (2.7.0)
Using rack (1.3.0)
Using rack-cache (1.0.2)
Using rack-mount (0.8.1)
Using rack-test (0.6.0)
Using hike (1.1.0)
Using tilt (1.3.2)
Using sprockets (2.0.0.beta.10)
Using tzinfo (0.3.29)
Using actionpack (3.2.0.beta) from source at
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.3.0)
Using actionmailer (3.2.0.beta) from source at
Using arel (2.1.3)
Using activerecord (3.2.0.beta) from source at
Using activeresource (3.2.0.beta) from source at
Using ansi (1.3.0)
Using bundler (1.0.15)
Using coffee-script-source (1.1.1)
Using execjs (1.2.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using rdoc (3.8)
Using thor (0.14.6)
Using railties (3.2.0.beta) from source at /Users/santiago/WyeWorks/Projs/rails
Using coffee-rails (3.2.0.beta) from
git://github.com/rails/coffee-rails (at master)
Using jquery-rails (1.0.12)
Using rails (3.2.0.beta) from source at /Users/santiago/WyeWorks/Projs/rails
Using sass (3.1.4)
Using sass-rails (3.1.1.alpha.0) from
git://github.com/rails/sass-rails (at master)
Using sqlite3 (1.3.3)
Using turn (0.8.2)
Using uglifier (1.0.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a
bundled gem is installed.
➜ /tmp cd myengine
➜ myengine rails g scaffold post
      invoke active_record
      create db/migrate/20110707161601_create_posts.rb
      create app/models/post.rb
      invoke test_unit
      create test/unit/post_test.rb
      create test/fixtures/posts.yml
       route resources :posts
      invoke scaffold_controller
      create app/controllers/posts_controller.rb
      invoke erb
      create app/views/posts
      create app/views/posts/index.html.erb
      create app/views/posts/edit.html.erb
      create app/views/posts/show.html.erb
      create app/views/posts/new.html.erb
      create app/views/posts/_form.html.erb
      invoke test_unit
      create test/functional/posts_controller_test.rb
      invoke helper
      create app/helpers/posts_helper.rb
      invoke test_unit
      create test/unit/helpers/posts_helper_test.rb
      invoke assets
      invoke coffee
      create app/assets/javascripts/posts.js.coffee
      invoke scss
      create app/assets/stylesheets/posts.css.scss
      invoke scss
      create app/assets/stylesheets/scaffolds.css.scss

yeah, I routed the engine in the main application routes as follows:

mount MyEngine::Engine => '/myengine'

and rake routes shows it as mounted as expected, it just doesnt
actually let you access it when running the server.

ok so it's working (to a degree on edge rails):

all the build, install etc work as expected (even generators within
the engine folder).

however, the following does not work when in the app I want to mount:

rake railties:install:migrations

it doesn't copy the migrations over from the engine into the app, just
does nothing silently.

Do I need to add something to the engine to expose them??


I had a similar problem. After some amazement the problem was in the
gemspec file. The config directory was not added with the gem and
therefore the routes are not loaded. Maybe adding Dir["congi/**/*"] to
myengine.gemspec will solve your problem.