I'm very new to Rails, and I'm trying to build a user authentication system with 'devise', but I am failing. I'm following Rails Girls Guides's tutorial on adding authentication using the gem 'devise'. Once I got to step 5, which is to set up the User model, I received this error after running rake db:migrate
rake aborted!
NoMethodError: undefined method `merge!' for #<ActionDispatch::Routing::Mapper::Scope:0x007fd3397a7448>
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:420:in `ensure in with_devise_exclusive_scope'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:420:in `with_devise_exclusive_scope'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:233:in `block (2 levels) in devise_for'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:336:in `block in devise_scope'
Has anyone solved this error? I've looked at all solutions such as not generating user model before installing devise, running bundle install, running rails g devise:install, and more. Nothing has worked so far when I'm trying to use devise for Rails 4.0.
Also, does anyone have recommendations on what tutorials I can follow to build an authentication system? I've tried a lot so far, and none has worked.
This looks to be a know bug with prior 3.4.0 devise.
Upgrading it should make this error go away.
To do that edit your Gemfile where you have gem "devise" <might have some other stuff in front> and change it to gem "devise", '~> 3.4.1'
then run bundle update devise and you are done.
Related
I am interested in playing around with the various stackdriver offerings, but I can't seem to get it to work with Rails. I added stackdriver to my Gemfile, ran bundle install and have added the config blocks.
Here's the error I am getting:
/usr/local/opt/rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.7.1/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `google_cloud' for #<Rails::Application::Configuration:0x007fbc843e0c18> (NoMethodError)
from /Users/preston/projects/myapp/config/environments/development.rb:74:in `block in <top (required)>'
I have tried requiring the Gem manually, among other things, and it doesn't seem like the code is getting loaded.
It turned out to be an issue that was causing an old version of the stackdriver gem (0.2.2) to be used. This happened due to a conflict with a different Google gem.
I started learning Ember.js using Rails as back-end, and created a test project. So, first I removed turbolinks from app and added the following gems to Gemfile:
gem 'ember-rails'
gem 'ember-source', '~> 1.8.1'
gem 'emblem-rails'
and bundled them. Next, I ran
$ rails g ember:bootstrap -n App --javascript-engine js
and it has returned me the following error:
/home/alex/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/emblem-rails-0.2.2/lib/emblem/rails/engine.rb:7:in
`block in <class:Engine>':
undefined method `register_engine' for nil:NilClass (NoMethodError)
Is the problem that something can be deprecated? I'm following the tutorial written in 2014.
The trouble was caused by emblem-rails gem - I commented it out, and everything worked
I took the following steps:
rails new routing_test
in Gemfile I added devise
rails devise g user
invoke active_record
create db/migrate/20130731191051_devise_create_users.rb
create app/models/user.rb
invoke rspec
create spec/models/user_spec.rb
invoke factory_girl
create spec/factories/users.rb
insert app/models/user.rb
route devise_for :users
and then, with a simple rake db:migrate, I get the following:
rake aborted!
Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007feb823b6120 #paths=["/Users/krg07/Developer/core2/test/dummy/config/routes.rb", "/Users/krg07/Developer/core2/config/routes.rb"], #route_sets=[#<ActionDispatch::Routing::RouteSet:0x007feb82c5e700>, #<ActionDispatch::Routing::RouteSet:0x007feb82d34440>]>
/Users/krg07/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated'
/Users/krg07/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
/Users/krg07/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
Any idea what is going on? Thanks, really appreciate it!
I had problems getting Devise to work with Rails 4 and found that most of the issues were because I was including an older version of the gem that was not updated to work with Rails 4. Specifying the latest version of the gem helped:
gem 'devise', '3.0.0'
You may need to re-run the Devise installer after the gem has been updated.
You are not the only one to have this problem, see the following issue for more informations.
I'm following through the "Learn Rails by Example" book, and I'm trying to run the tests. For some reason I can't get rspec to work properly.
If I run the rspec spec/ command as he instructs, I get the following error:
$ rspec spec/
/home/desktop/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in `block in setup':
You have already activated rspec-core 2.7.1, but your Gemfile requires rspec-core 2.6.4.
Using bundle exec may solve this. (Gem::LoadError)
The odd thing is my Gemfile doesn't specify version--
group :development do
gem 'rspec-rails'
end
group :test do
gem 'rspec'
gem 'webrat'
end
If I follow the advice from the error message and use bundle exec rspec spec/ then the first two tests pass-- but the new "about" page we built in the tutorial fails with the following error, even though as far as I can tell the page I'd built (and controller actions etc.) are exactly as they should be:
Failures:
1) PagesController GET 'about' should be successful
Failure/Error: response.should_be_success
NoMethodError:
undefined method `should_be_success' for #<ActionController::TestResponse:0x00000003539438>
# ./spec/controllers/pages_controller_spec.rb:23:in `block (3 levels) in <top (required)>'
Finished in 0.10861 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/controllers/pages_controller_spec.rb:21 # PagesController GET 'about' should be successful
I'm a pretty experienced programmer but I've run into endless issues with conflicting gem versions and a hundred different ways to accomplish all the different tasks using Rails (eg. "use RVM", "Don't use RVM", "install gems using sudo", "don't install gems using sudo" etc.)
My dev machine is running ubuntu linux.
Thanks for any help-- please explain if you would what I'm doing wrong in Ruby noob language!
Running bundle exec is correct, and is needed because you have a newer version of that gem installed that gets loaded instead of the one specified in your Gemfile.lock. Using bundle exec overrides the load path, causing only the gems specified in your Gemfile.lock to be loaded. (You may find it handy to alias bundle exec to something shorter.)
The answer to the second problem is right in the error messages:
undefined method `should_be_success'
it should be should be_success.
I just changed my Rails 2.3.8 project to load gems using Bundler, rather than the default Rails 2.3 loading mechanism. I followed the official instructions and the site runs fine in development. I use RVM for gem management, and have a specific gemset loaded for the application.
My RSpec test suite is unable to run, however. I have tried running both the entire suite and single tests using a variety of commands:
autospec # My usual way of running tests
rake spec
spec .
spec spec/models/comment_spec.rb # Trying a single spec file in isolation
ruby spec/models/comment_spec.rb
I have also tried running them all prefixed with bundle exec. Everything returns the same error:
/Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant InheritedResources::Base (NameError)
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing_not_from_s3_library'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
from /Users/casper/Projects/cf/darebusters/app/controllers/admin/base_controller.rb:1
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in `require'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in `require'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:265:in `require_or_load'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:224:in `depend_on'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:136:in `require_dependency'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/rails-2.3.8/lib/initializer.rb:414:in `load_application_classes'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/rails-2.3.8/lib/initializer.rb:413:in `each'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/rails-2.3.8/lib/initializer.rb:413:in `load_application_classes'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/rails-2.3.8/lib/initializer.rb:411:in `each'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/rails-2.3.8/lib/initializer.rb:411:in `load_application_classes'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/rails-2.3.8/lib/initializer.rb:197:in `process'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
from /Users/casper/.rvm/gems/ruby-1.8.7-p248#darebusters/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
from /Users/casper/Projects/cf/darebusters/config/environment.rb:9
from /Users/casper/Projects/cf/darebusters/spec/spec_helper.rb:5:in `require'
from /Users/casper/Projects/cf/darebusters/spec/spec_helper.rb:5
from spec/models/comment_spec.rb:1:in `require'
from spec/models/comment_spec.rb:1
I'm pretty sure the problem is not related to the Inherited Resources gem - I think gems are not loaded at all at this point, and Inherited Resources just happens to be the first one needed.
The thing that's baffling me is that /activesupport-2.3.8/lib/active_support/dependencies.rb:158 requires /app/controllers/admin/base_controller during the initialization phase. It shouldn't do that, and it certaintly doesn't do it in development mode. I can comment out gem 'inherited_resources' in my Gemfile, and site still runs. It's not until I hit an action that loads a controller that use Inherited Resources I get the "uninitialized constant" error.
For clarity, here's my Gemfile and spec_helper.rb.
Even older question, but I had the same issue with Bundler 1.0.3, Rspec-Rails 1.3.3 & Rails 2.3.8 and was able to boil it down to remarkable_rails. Remarkable-Rails seems to load rspec/rails before the initializers are run by the environment.
After adding :require => nil to it in the Gemfile and requiring it by hand in spec_helper AFTER requiring the rails-environment the issue disappeared.
I realize this is an old question, but I just came across the same problem.
I had the 1.3.0 version of rspec and rspec-rails required by my application. Looking at the rspec-rails changelog, I noticed there were a few bug fixes after 1.3.0. Upgrading rspec-rails to 1.3.2 fixed everything for me.
To fix this problem I changed by Gemfile from:
gem 'rspec-rails', '~> 1.3.2', :require => 'spec/rails'
to
gem 'rspec-rails', '~> 1.3.2'
and added the following to my spec helper
require 'spec/rails'