I'm trying to get user authentication with devise working, and failing.
I tried following the steps in the RailsGirls article, but after creating the simple new project, adding the gem 'devise' and running bundle install, but when I run rails generate devise:install I get a screenful of errors starting
Error:Get available generators script executes with errors:
Error:C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `devise' for User (call 'User.connection' to establish a connection):Class (NoMethodError)
Has anybody any idea what I might be doing wrong? (I tried using the instructions in the devise wiki, but I couldn't get it working that way either).
I just ran to this same problem today, it's because you tried to generate the model before you tried to install devise it self
Stash ( or remove ) the changes for the user model and any migration file, then run this
rails generate devise:install
after that unstash and apply the migration, it should work just fine.
Related
I'm working on a project where we are migrating from an old ruby web api (not rails) that was pulling in activeSupport and activeRecord 4.1.8 and using resque 1.25.2 for jobs to a new rails 4.2.4 project using resque 1.25.2 for job processing as well. Everything has been going pretty smoothly until I started a resque work to process jobs and I got:
NoMethodError: undefined method 'synchronize' for ActiveRecord::AttributeMethods::GeneratedAttributeMethods
This error is only thrown when User.find_by_id or User.new is called within the context of a worker process. This same error is thrown when calling several other models as well but not all of them. Company.new, for example, doesn't throw the error and if I rename the User model to say Companya the error goes away... Running ruby 2.2.3 on the rails app.
Any help would be greatly appreciated.
I guess I've encountered the issue once...
The exception would be raised when Rails failed to find the method that was generated dynamically. So the case I can imagine is that Rails (ActiveRecord) did not define the methods dynamically.
The matters which should be checked are...
restarting resque and KVS.
models' class names, parent classes (should be ActiveRecord::Base) and migration files if that follow Rails naming conventions correctly. See here: http://guides.rubyonrails.org/active_record_basics.html#naming-conventions
reset and migrate again in all environments with the argument like $ bin/rake db:migrate:reset RAILS_ENV=production
stopping the Spring once by $ bin/spring stop. (It restarts automatically when the next bin command is called.)
hmm...Can you use those methods in rails console?
Hope it would help...!
`synchronize' error happens when the related gem is not up to date. I belive if you update your installed gems then the issue would be resolved.
I'm new to ROR, I have recently included DEVISE into my Rails project but accidentally I ran a wrong command as follows:
rails g devise install
After that rails starting showing errors and not working, even the server is not running now.
Here's a screenshot showing the number of errors I'm getting and their details:
Now even the normal command for installing devise, i.e. devise:install is not working.
Does this command work for you? rails destroy devise:install
This should delete your Devise configuration.
I created a rails project MyProject and tried to set up Devise in it (using this tutorial). After I did some Devise stuff I could not scaffold User anymore, I ran into an error as shown below. So I wanted to start over, renamed the project to MyProject-Devise and created a new project MyProject to create User first and then do my Devise stuff. Now in my new project of the same name, when I run
rails generate scaffold user name:string email:string
I run into the same error. If I create a new app with another name, I can scaffold the user with the same command. So I guess it must be the same name thing.
Any ideas why this happens? How to get rid of the error or how to properly start the project over again?
This is the error:
/Users/luke/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/inflector/methods.rb:238:in `const_get': uninitialized constant User (NameError)
Full error here: http://pastebin.com/KFh4U6aS
It looks like you might not be using Bundler. The tutorial you linked to had you create a Gemfile but didn't tell you to run bundle or bundle exec. Without Bundler you may be using a Devise installed directly into your Ruby's gems.
I suspect if you run the rails generate command with bundle exec you may have different results.
bundle exec rails generate scaffold user name:string email:string
I am using mailboxer in my Rails 4 app.
gem 'mailboxer'
I recently updated it from 0.11 to 0.12.4, it stopped working, and I cant figure out why. Now, I am getting the error:
uninitialized constant Message
I checked the gem's GitHub repo and it does have the Message model.
I checked my local version of the gem and it matches up.
Puma:mailboxer Jeff$ pwd
/Users/Jeff/.rvm/gems/ruby-2.0.0-p247/gems/mailboxer-0.12.4/app/models/mailboxer
Puma:mailboxer Jeff$ ls
conversation conversation.rb mailbox.rb message.rb notification.rb receipt.rb
Why isn't my app finding the model? How do I fix this?
Message is now namespaced as Mailboxer::Message. According to the upgrade documentation, you also need to run through a few steps when upgrading from 0.11 to 0.12:
rails generate mailboxer:namespacing_compatibility
rails generate mailboxer:install -s
rake db:migrate
I installed devise 1.1.rc0 and haven't been able to get it to work in my existing application.
I changed the gem file to gem 'devise' without specifying the version. Ran bundle install. Then ran rail destroy devise_install since that's the command I used to install it.
*Then when I tried to reintall with rails generate devise:install it gives me this error:
gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:50:in method_missing': undefined methoddevise' for # (NoMethodError)*
Ryan Bigg helped me figure out the above error was caused by the user model making a reference to devise, which after the uninstall causes an error. So I removed that reference.
Now I have this error.
gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize': uninitialized constant User (NameError)
What is this referring to?
You're getting this error because Devise isn't configured, yet your model references it. Remove the call to the devise method (or comment it out) in any model that references it.
I found the same issue when upgrading from 1.8.7 and Rails 3.0.7 to 1.9.3 and Rails 3.2.8. The solution involves removing:
gem 'active_reload'