NoMethodError in Devise::RegistrationsController#create - ruby-on-rails

I have added the Devise gem to the ruby on rails app version 1.8.7. I using devise to authenticate and also I have created a model called user which will connect another database, I have mentioned/specified the database configurations in the create_connection,whenever I run the app in the local host, I am getting this error message
"undefined method `password_salt=' for #"
As soon as I register a new member I am getting this error.
I am a newbie to rails,
Kindly help me out

i had this error once before, try the following
1.Re-run your migrations again
rake db:migrate VERSION=0 #to rollback migrations to the first one if needed<br />
Just in case you have forgotten, uncomment the following line
t.string :password_salt
then migrate your database
rake db:migrate
Also make sure that encryptable is added to your database model
devise :encryptable .....
2.Update your devise gem
bundle update or specify in your gem file to use latest devise gem 2.x

You will need to add the password_salt column to your users table. It appears to be missing.

Related

Rails 5 project without activerecord causing model generate error

I'm facing a problem in a project using Rails 5.2 without ActiveRecord.
I've runned the command rails new project --skip-active-record and it's ok, but when I run a command to generate a model I get this error:
.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/rubygems_integration.rb:404:in
`block (2 levels) in replace_gem': Error loading the 'sqlite3' Active
Record adapter. Missing a gem it depends on? sqlite3 is not part of
the bundle. Add it to your Gemfile. (Gem::LoadError)
I didn't understand why it ask about sqlite 3 in active record if I disabled it and I search over internet and don't find anyone talking about.
What is wrong?
Thanks
If you don't want to use ActiveRecord then there's no need to generate a model using rails g.
You can just go to the app/models directory in your application and create a plain ruby class to work with it as a model.
The command
rails g model MODEL
will generate model, migration and fixtures. And this is related to ORM. So rails will look at database configuration. There you would have mentioned the ORM client as
adapter: sqlite3
You need to install sqlite3 gem for this. Add
gem 'sqlite3'
to your Gemfile
If you want to add just model alone create file inside app/models folder. But whats the point in doing this? Rails will look for the table name respect to the model's class name and throw an error
I assume you don't have an ORM. If that is the case then running rails generate model shouldn't do anything, it shouldn't even install sqlite by default. Try updating your sqlite gem
The $ bin/rails generate model ... command actually creates a migration and an ActiveRecord model that's why you get the database-related error. See Model Generators.

ruby on rails authentication using devise gem

Am using devise gem for authentication
When i run rake db:migrate
I got the error mentioned below:
rake aborted!
User does not respond to 'devise' method.
This usually means you haven't loaded your ORM file or it's being loaded too late.
To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb'
or before your application definition in 'config/application.rb'
If you know answer. Please let me know..
In the file config/initializers/devise.rb look for the line:
require 'devise/orm/active_record'
Make sure that it isn't commented out, and make sure it matches your orm.
If that file doesn't exist, then you haven't installed devise:
rails generate devise:install
Have a good read of the Getting Started instructions

Devise not working with Rails 4.0

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.

RoR using Devise - Encrypted Password

Hi pardon my ignorance but I'm new to RoR. My problem is that I'm trying to make my Devise gem work but when I fill out the information and click Sign-Up, I get this in return: "undefined method `encrypted_password=' for".
I've already tried rake db:migrate and also clearing the attributes in the User.rb model but still it doesn't work.
Please any guidance would be appreciated!
This most likely means, that you are missing on migrations.
Are you sure, that you have setup devise right?
https://github.com/plataformatec/devise
rails generate devise:install
rails generate devise User
bundle exec rake db:migrate
In the rails console run, this will tell you if the migration has run
User.new.respond_to?(:encrypted_password=)
This should return true, if not do
bundle exec rake db:migrate:reset
In the site railscasts.com you can watch:
http://railscasts.com/episodes/209-introducing-devise
after that you understand where you make a mistake
If you then get an error - write comments and we help
P.S. gem 'devise', '1.1.rc0' => gem 'devise' in gemfile

how to implement "has_messages_generator" on rails3 with devise?

I already created App that I would like to add "has_message_generator" into it.
an auth plugin "Devise" is already installed,so that I followed these dierection below.
Add this line to my Gemfile and did bundle install
gem "has_messages_generators"
Did this command line and it seemed everything's ok!
rails g has_messages:install user
But it shows "uninitialized constant User::HasMessages" error when I access to root page.
so I took "include HasMessages" off from user.rb(in Model directory)
and did "bundle exec rake db:migrate"
It seemed it created table successfully.
Then I tried to access to root page, it still shows error "undefined methodinbox' for #"`
Anyone has idea with the installation of this plugin???
You have to install has_messages, too:
… to use this you must include devise and has_messages in your Gemfile.

Resources