TypeError:rake命令后错误的参数类型Class(expected Module)

时间:2015-12-03 15:04:46

标签: ruby-on-rails ruby gem mongoid

当我试图" rake db:mongoid:create_indexes" ,我有一个错误。添加" gem' mongoid',gem' bson_ext' "到我的Gemfile和bundle install。在下面运行bundle install安装文件之后;

已安装的文件

 Installing bson 1.12.5
 Installing bson_ext 1.12.5 with native extensions
 Installing durran-validatable 2.0.1
 Installing leshill-will_paginate 2.3.11
 Installing mongo 1.12.5
 Installing mongoid 1.0.6

错误

 $ rake db:mongoid:create_indexes --trace
   rake aborted!
   TypeError: wrong argument type Class (expected Module)
   /Library/Ruby/Gems/2.0.0/gems/leshill-will_paginate-2.3.11/lib/will_paginate.rb:78:in `extend'
   /Library/Ruby/Gems/2.0.0/gems/leshill-will_paginate-2.3.11/lib/will_paginate.rb:78:in `<module:Deprecation>'
   /Library/Ruby/Gems/2.0.0/gems/leshill-will_paginate-2.3.11/lib/will_paginate.rb:77:in `<module:WillPaginate>'
  .
  .
  .
  /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
  /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
  .
  .
  .
  /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `load'
  /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `load_rakefile'
  /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:689:in `raw_load_rakefile'
  .
  .
  /usr/local/bin/rake:23:in `load'
  /usr/local/bin/rake:23:in `<main>'

宝石文件

gem 'rails', '4.2.4'
gem 'bcrypt', '~> 3.1.7'
gem 'faker',                '1.4.2'
gem 'carrierwave',             '0.10.0'
gem 'mini_magick',             '3.8.0'
gem 'fog',                     '1.36.0'
gem 'will_paginate',           '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'
gem 'geocoder'
gem 'mongoid'
gem 'bson_ext'

group :development, :test do
gem 'sqlite3'
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end

的database.yml

 development:
 <<: *default
    database: db/development.sqlite3

location.rb

  class Location < ActiveRecord::Base
   belongs_to :user
   belongs_to :micropost

   include Geocoder::Model::Mongoid
    geocoded_by :address               # can also be an IP address
    after_validation :geocode          # auto-fetch coordinates
    reverse_geocoded_by :coordinates
    after_validation :reverse_geocode  # auto-fetch address

  end

location.rb

 class CreateLocations < ActiveRecord::Migration
 def change
  create_table :locations do |t|
    t.float :latitude
    t.float :longitude
    t.references :user, index: true, foreign_key: true
    t.references :micropost, index: true, foreign_key: true

    t.timestamps null: false
   end
  end
 end

0 个答案:

没有答案