0

使用 Rails 生成新项目。

将 twitter-bootstrap-rails 添加到 Gemfile

    source 'https://rubygems.org'

    gem 'rails', '3.2.8'
    # Use thin as webserver
    gem 'thin'
    # Mysql
    gem 'mysql2'
    # Gems used only for assets and not required
    # in production environments by default.
    group :assets do
      gem 'sass-rails',   '~> 3.2.3'
      gem 'coffee-rails', '~> 3.2.1'
      # See https://github.com/sstephenson/execjs#readme for more supported runtimes
      gem 'therubyracer', :platforms => :ruby
      gem "less-rails"
      gem 'uglifier', '>= 1.0.3'
    end
    # Twitter bootstrap baby
    gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
    # json
    gem 'json'
    # jQuery is the win
    gem 'jquery-rails'
    gem 'jquery-ui-rails'
    # Devise for auth goodness
    gem 'devise'
    # Cancan for permission goodness
    gem 'cancan'

    # Fog allows for easy communication with clouds
    gem 'fog'

    group :development, :test do
      # Cannot run as gem and use heroku
      # See: http://stackoverflow.com/questions/6288910/heroku-deployment-gemfile-lock-problem
      # gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
      gem 'faker'
      gem 'factory_girl_rails'
      gem 'rspec-rails'
      gem 'shoulda-matchers'
      gem 'capybara'
      gem 'launchy'
      gem 'database_cleaner'
      gem 'guard-rspec'
    end

    # 
    # group :production do
    #   gem 'pg'
    # end

做了一个捆绑安装,一切顺利。

然后我做了

    $ rails g bootstrap:install

仍然一切都很好。

接下来,这样做:

    $ rails g bootstrap:layout application fixed

还好。

然后我这样做了:

    $ rails g bootstrap:themed Posts

得到了这个:

    /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize': uninitialized constant Post (NameError)
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:59:in `block in columns'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:69:in `rescue_block'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:58:in `columns'
        from (erb):9:in `template'
        from /Users/jason/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/erb.rb:838:in `eval'
        from /Users/jason/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/erb.rb:838:in `result'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/file_manipulation.rb:111:in `block in template'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:54:in `call'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:54:in `render'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:47:in `identical?'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:73:in `on_conflict_behavior'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/empty_directory.rb:130:in `invoke_with_conflict_check'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:61:in `invoke!'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions.rb:95:in `action'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:26:in `create_file'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/file_manipulation.rb:110:in `template'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:97:in `block in generate_erb'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:96:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:96:in `generate_erb'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:92:in `generate_views'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:19:in `copy_views'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `block in invoke_all'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `map'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `invoke_all'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/group.rb:238:in `dispatch'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/generators.rb:171:in `invoke'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/generate.rb:12:in `<top (required)>'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:29:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
    /Volumes/dev/projects/jason/fuckthis $ rails g bootstrap:themed posts
    /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize': uninitialized constant Post (NameError)
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:59:in `block in columns'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:69:in `rescue_block'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:58:in `columns'
        from (erb):9:in `template'
        from /Users/jason/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/erb.rb:838:in `eval'
        from /Users/jason/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/erb.rb:838:in `result'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/file_manipulation.rb:111:in `block in template'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:54:in `call'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:54:in `render'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:47:in `identical?'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:73:in `on_conflict_behavior'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/empty_directory.rb:130:in `invoke_with_conflict_check'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:61:in `invoke!'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions.rb:95:in `action'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:26:in `create_file'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/file_manipulation.rb:110:in `template'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:97:in `block in generate_erb'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:96:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:96:in `generate_erb'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:92:in `generate_views'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:19:in `copy_views'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `block in invoke_all'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `map'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `invoke_all'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/group.rb:238:in `dispatch'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/generators.rb:171:in `invoke'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/generate.rb:12:in `<top (required)>'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:29:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
    /Volumes/dev/projects/jason/fuckthis $ rails g bootstrap:themed posts -f
    /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize': uninitialized constant Post (NameError)
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:59:in `block in columns'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:69:in `rescue_block'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:58:in `columns'
        from (erb):9:in `template'
        from /Users/jason/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/erb.rb:838:in `eval'
        from /Users/jason/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/erb.rb:838:in `result'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/file_manipulation.rb:111:in `block in template'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:54:in `call'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:54:in `render'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:47:in `identical?'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:73:in `on_conflict_behavior'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/empty_directory.rb:130:in `invoke_with_conflict_check'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:61:in `invoke!'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions.rb:95:in `action'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/create_file.rb:26:in `create_file'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/actions/file_manipulation.rb:110:in `template'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:97:in `block in generate_erb'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:96:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:96:in `generate_erb'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:92:in `generate_views'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/twitter-bootstrap-rails-2.1.6/lib/generators/bootstrap/themed/themed_generator.rb:19:in `copy_views'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `block in invoke_all'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `each'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `map'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `invoke_all'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/group.rb:238:in `dispatch'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/generators.rb:171:in `invoke'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/generate.rb:12:in `<top (required)>'
        from /Users/jason/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:29:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

我已经回滚到 twitter-bootstrap-rails 2.1.5 和 2.1.4 无济于事。

请指教。

4

1 回答 1

5

您需要先创建 Post 脚手架。来自https://github.com/seyhunak/twitter-bootstrap-rails/blob/master/README.md

rails g scaffold Post title:string description:text
rake db:migrate
rails g bootstrap:themed Posts
于 2012-11-19T21:05:07.553 回答