When using kaminari with mongoid, I get the error
undefined method `page' for #<Mongoid::Contextual::Mongo:0x007fe48c195af0>
Not sure what is wrong. I even tried running
Item.page(params[:page])
and I get the error
NoMethodError: undefined method `page' for Item:Class
The gem is present in the Gemfile. Double checked.
I see you are using mongoid, in that case add to the Gemfile will_paginate_mongoid gem and run $ bundle
More info can be found here and here.
Related
I have a strange error in my rails project. I use ruby 2.1.1#rails4.1.1 and recently added a gem "tinymce-rails".
Everything was working fine until this gem was added. I can't turn on my server in development mode nor production.
The error is:
NoMethodError: undefined method `new' for #<Grease::Adapter(Less::Rails::ImportProcessor):0x0000000702fce0>
(in /mnt/c/repo/intratur/app/assets/stylesheets/application.css)
Please help me!, I don't what to do!
Grease gem dependency is only for "less-rails" greater or equal to 3.0.0. You can set the gem version to less than 3.0 to resolve it.
Reference: undefined method `new' for #<Grease::Adapter(Less::Rails::ImportProcessor)
I add gem 'mithril_rails' in my Gemfile, make bundle install and bundle update, add //= require mithril in my application.js file, type rails s and get error:
/Users/myusername/.rvm/gems/ruby-2.2.2/gems/mithril_rails-0.0.7/lib/mithril_rails/rails/engine.rb:5:in block in <class:Engine>': undefined methodregister_engine' for
nil:NilClass (NoMethodError)
I use rails 4.2.3, mongoid.
What can I do?
You can use 'sprockets 2.12.3'. The issue relating to sprockets and already reported.
I am following a Rails tutorial and have to run rails console. I never had a issue with it before but now it doesn't run.
Here's the error.
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.11/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `generators' for
#<Rails::Railtie::Configuration:0x007ffc41d4a9a0> (NoMethodError)
from /Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/rspec-rails-2.0.0.beta.18/lib/rspec-rails.rb:4:in `<class:Railtie>'
I noticed that your rspec gem is the same version as listed here: "rails generate rspec:install" seems to be failing
Maybe that will help.
Error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/devise-1.0.11/lib/devise.rb:89:in '': undefined method 'weeks' for 2:Fixnum (NoMethodError)
That error is thrown whenever I try to run 'rails g devise:install' in a rails project I've been working on.
Any ideas?
P.S. requiring gem 'devise' in Gemfile and running bundle install to get the devise gem
This issue was already dealt with here. Try updating to a later devise version to fix.
I'm learning Rails with the awesome Ruby on Rails Tutorial by Michael Hartl. I'm on section 3.2.2 (Test Driven Development) in which I need to run the following command to run the rspec tests for my Rails project:
bundle exec rspec spec/
But it doesn't work. Instead I get this error:
/Users/mh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/
activerecord-3.1.3/lib/active_record/base.rb:1088:in `method_missing':
undefined method `mass_assignment_sanitizer=' for
ActiveRecord::Base:Class (NoMethodError)
I've tried reinstalling rspec and changing my Gemfile, but nothing appeases the undefined method error!
Did you downgrade from Rails 3.2 RC1? Comment out the following two lines from your development.rb:
config.active_record.mass_assignment_sanitizer = :strict
config.active_record.auto_explain_threshold_in_seconds = 0.5
While m818's answer will solve the problem, you might still get errors if you are tyring to use deprecated methods elsewhere in your code.
I had the same problem, commenting out those lines got rid of some errors, but not all of them, anywhere I was using attr_accessible gave me the same error.
It turned out to be the `active_record' gem that was updated to 4.0 when I didn't want it to. Since I'm using a Padrino app, I had to do this in the Gemfile:
gem 'activerecord', '= 3.2.12', :require => "active_record"
That solved all issues and I didn't have to comment out the lines in database.rb.