Reputation: 1216
I have a Rails application which was using Mongoid 4.0.2. I upgraded Mongoid to version 5.0.0 and start getting this error
....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)
How to fix this issue or is any manual how to upgrade Mongoid to version 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
Upvotes: 1
Views: 1822
Reputation: 4052
It looks like the error has appeared again in less-rails. The error is not related to Mongoid at all. I started getting the error a couple of days ago on my development server. I decided to check Github to see if an issue was reported about this. I found the following issue addressing the error.
https://github.com/metaskills/less-rails/pull/112
I changed my Gemfile to the following as provided on the link which corrected the error.
gem "less-rails", :git => 'https://github.com/suzan2go/less-rails.git', :branch => 'fix-nomethoderror-for-sprockets3'
As of now this solution has not been applied to the gem. I guess it will be soon.
Upvotes: 2
Reputation: 5691
Most important thing to look for while upgrading to Mongoid 5 is mongoid.yml
From:
<%= rails_env %>:
sessions:
default:
database: <%= mongodb_database %>
hosts:
- <%= mongodb_staging_host %>
username: <%= mongodb_user %>
password: <%= mongodb_password %>
options:
read: :primary_preferred
To:
<%= rails_env %>:
clients:
default:
database: <%= mongodb_database %>
hosts:
- <%= mongodb_staging_host %>
options:
user: <%= mongodb_user %>
password: <%= mongodb_password %>
read:
mode: :primary_preferred
sessions
to clients
username
(will become user
) and password
into options
read
mode as shown, if you have any.Bottomline is to check mongoid.yml thoroughly while comparing with this page
Upvotes: 1
Reputation: 1216
Here how I fixed this issue
Removed from Gemfile gem "less-rails"
From application.rb removed require "mongo"
In mongoid.yml changed sessions:
to clients:
Upvotes: 0