使用 bootstrappers 產生專案出現問題

想用 bootstrappers 快速產生一個專案卻出現以下問題:

Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
 generate devise:install
/Users/martin/myapp/config/application.rb:7:in `<top (required)>': uninitialized constant Bundler (NameError)
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:43:in `<top (required)>'
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
 from bin/rails:4:in `<main>'
 generate devise User
/Users/martin/myapp/config/application.rb:7:in `<top (required)>': uninitialized constant Bundler (NameError)
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:43:in `<top (required)>'
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
 from /Users/martin/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
 from bin/rails:4:in `<main>'
/Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/bootstrappers-4.2.1/lib/bootstrappers/actions.rb:10:in `read': No such file or directory - /Users/martin/myapp/config/initializers/devise.rb (Errno::ENOENT)
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/bootstrappers-4.2.1/lib/bootstrappers/actions.rb:10:in `replace_in_file'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/bootstrappers-4.2.1/lib/bootstrappers/app_builder.rb:53:in `replace_email_sender_for_devise'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/generators/app_base.rb:88:in `build'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/bootstrappers-4.2.1/lib/bootstrappers/generators/app_generator.rb:108:in `setup_devise'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `block in invoke_all'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `each'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `map'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `invoke_all'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/group.rb:233:in `dispatch'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/gems/bootstrappers-4.2.1/bin/bootstrappers:12:in `<top (required)>'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/bin/bootstrappers:23:in `load'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/bin/bootstrappers:23:in `<main>'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
 from /Users/martin/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'

看來是 devise 這個套件出了問題。

起初谷歌了一下,是找到相類問題,但並沒有解法。

後來嘗試手動輸入安裝指令:

martin@martins-mba:~/myapp$ rails g devise:install
 create config/initializers/devise.rb
 create config/locales/devise.en.yml
===============================================================================
Some setup you must do manually if you haven't yet:
1. Ensure you have defined default url options in your environments files. Here
 is an example of default_url_options appropriate for a development environment
 in config/environments/development.rb:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
In production, :host should be set to the actual host of your application.
2. Ensure you have defined root_url to *something* in your config/routes.rb.
 For example:
root :to => "home#index"
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
 For example:
<p class="notice"><%= notice %></p>
 <p class="alert"><%= alert %></p>
4. If you are deploying on Heroku with Rails 3.2 only, you may want to set:
config.assets.initialize_on_precompile = false
On config/application.rb forcing your application to not access the DB
 or load models when precompiling your assets.
5. You can copy Devise views (for customization) to your app by running:
rails g devise:views
===============================================================================

martin@martins-mba:~/myapp$ rails g devise User
 invoke active_record
 create db/migrate/20140212190200_devise_create_users.rb
 create app/models/user.rb
 invoke test_unit
 create test/models/user_test.rb
 create test/fixtures/users.yml
 insert app/models/user.rb
 route devise_for :users

martin@martins-mba:~/myapp$ rake db:migrate
== DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
 -> 0.0505s
-- add_index(:users, :email, {:unique=>true})
 -> 0.0019s
-- add_index(:users, :reset_password_token, {:unique=>true})
 -> 0.0009s
== DeviseCreateUsers: migrated (0.0538s) =====================================

問題好像就解決了!

Reference:

請問我用bootstrappers新建後,bundle install成功,rake db:c… << Rails 101 « bumblr