2

I have a rails app in which I am using devise gem for user signup and login. I followed all the steps to use devise: added following to gemfile

gem 'devise' 

then

bundle install

After executing

rails g devise:install 

I ran the following command

rails g devise user

After this I did

rake db:migrate

Everything goes well, devise gem got installed migration was also successful and the url

http://localhost:3000/users/sign_up 

shows the signup form. But after filling the data on clicking signup button nothing is happening. No error on console. No data is being inserted to the table. Any help would be appreciable.

console log

Started GET "/users/sign_up" for 127.0.0.1 at 2015-06-06 15:04:56 +0530
  ActiveRecord::SchemaMigration Load (0.3ms)  SELECT `schema_migrations`.* FROM `schema_migrations`
Processing by Devise::RegistrationsController#new as HTML
  Rendered /home/ajeet/.rvm/gems/ruby-2.2.0/gems/devise-3.4.1/app/views/devise/shared/_links.html.erb (5.5ms)
  Rendered /home/ajeet/.rvm/gems/ruby-2.2.0/gems/devise-3.4.1/app/views/devise/registrations/new.html.erb within layouts/application (28.3ms)
Completed 200 OK in 278ms (Views: 257.9ms | ActiveRecord: 1.0ms)

User devise migration file content

def change
create_table(:users) do |t|
  ## Database authenticatable
  t.string :email,              null: false, default: ""
  t.string :encrypted_password, null: false, default: ""

  ## Recoverable
  t.string   :reset_password_token
  t.datetime :reset_password_sent_at

  ## Rememberable
  t.datetime :remember_created_at

  ## Trackable
  t.integer  :sign_in_count, default: 0, null: false
  t.datetime :current_sign_in_at
  t.datetime :last_sign_in_at
  t.string   :current_sign_in_ip
  t.string   :last_sign_in_ip

  ## Confirmable
  # t.string   :confirmation_token
  # t.datetime :confirmed_at
  # t.datetime :confirmation_sent_at
  # t.string   :unconfirmed_email # Only if using reconfirmable

  ## Lockable
  # t.integer  :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
  # t.string   :unlock_token # Only if unlock strategy is :email or :both
  # t.datetime :locked_at

  t.timestamps
end

add_index :users, :email,                unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token,   unique: true
# add_index :users, :unlock_token,         unique: true
 end
end

Database is mysql content of routes.rb file

devise_for :users
root 'home#index'
get 'home/index'
Nitin Rajan
  • 309
  • 2
  • 18
Ajeet Khan
  • 8,582
  • 8
  • 42
  • 65

1 Answers1

1

In your User Model add :confirmable and set your root to: in your routes.rb.

  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :confirmable

Your routes.rb should look like something like this:

root to: 'home#index'

I forgot to add, please uncomment these lines:

 ## Confirmable
  # t.string   :confirmation_token
  # t.datetime :confirmed_at
  # t.datetime :confirmation_sent_at
  # t.string   :unconfirmed_email # Only if using reconfirmable

You can use Heroku to get a free SendGrid account for e-mail activation.

Bottom of your dev environment:

config.action_mailer.default_url_options = { host: 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
Jonathan Musso
  • 1,374
  • 3
  • 21
  • 45