我有一个使用Mongoid 4.0.2的Rails应用程序。我将Mongoid升级到版本5.0.0并开始收到此错误
....gems/2.2.0/gems/less-rails-2.7.0/lib/less/rails/railtie.rb:19:in `block in <class:Railtie>': undefined method `register_preprocessor' for nil:NilClass (NoMethodError)
如何解决此问题或是否有任何手册如何将Mongoid升级到5.0.0版本?
的Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0.beta4'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0.beta1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jQuery as the JavaScript library
gem 'jquery-rails', '~> 4.0.0.beta2'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#new gems
#database
gem 'mongoid', '~> 5.0.0.beta'
gem "mongoid-paperclip", :require => "mongoid_paperclip"
gem 'bson_ext'
#stile
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'bootstrap_form'
gem 'bootstrap-sass', '~> 3.3.4'
gem 'bootswatch-rails'
gem 'simple_form'
gem 'mongo'
gem "figaro"
gem 'sidekiq'
gem 'sidekiq-status'
gem 'rubyzip'
#gem 'sidekiq_status'
#gem 'sidekiq-status'
gem 'sinatra', require: false
gem 'slim'
gem 'capistrano', '~> 3.1.0'
# rails specific capistrano funcitons
gem 'capistrano-rails', '~> 1.1.0'
gem 'capistrano-rails-console'
# integrate bundler with capistrano
gem 'capistrano-bundler'
# if you are using RBENV
gem 'capistrano-rbenv', "~> 2.0"
gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'
gem 'capistrano-passenger'
gem 'utf8-cleaner'
gem "devise"
gem 'rollbar', '~> 1.5.3'
#gem 'bson', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
gem 'thin'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0.0.beta4'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
#new gems
gem "rspec-rails"
gem 'pry-rails'
gem 'pry-rescue'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'better_errors'
#gem 'mongoid-rspec', '~> 2.1.0'
end
答案 0 :(得分:0)
我在这里解决了这个问题
从Gemfile gem "less-rails"
从application.rb中移除require "mongo"
在mongoid.yml中将sessions:
更改为clients:
答案 1 :(得分:0)
升级到Mongoid 5时要注意的最重要的事情是mongoid.yml
自:
<%= rails_env %>:
sessions:
default:
database: <%= mongodb_database %>
hosts:
- <%= mongodb_staging_host %>
username: <%= mongodb_user %>
password: <%= mongodb_password %>
options:
read: :primary_preferred
要:
<%= rails_env %>:
clients:
default:
database: <%= mongodb_database %>
hosts:
- <%= mongodb_staging_host %>
options:
user: <%= mongodb_user %>
password: <%= mongodb_password %>
read:
mode: :primary_preferred
sessions
更改为clients
username
(将成为user
)和password
移至options
read
模式,如果有的话。Bottomline是在与this page
比较时彻底检查mongoid.yml