0

Hi I have added active_admin to my rails app. I would like to create a new AdminUser.

Based on this documentation I tried to create a user and have the app send out an email. The user was created fine in the app, but no email was sent out. I was wondering if anyone can give me suggestions as to why this is not working. Ive double checked my code and its exactly how the documentation says it should be.

What am I missing to make the email be sent out?

Here are the relevant classes

admin/admin_users.rb

ActiveAdmin.register AdminUser do

index do
  column  :email
  column  :current_sign_in_at
  column  :last_sign_in_at
  column  :sign_in_count
  default_actions
end

form do |f|
    f.inputs "Admin Details" do
      f.input :email
    end
    f.buttons
 end
end

models/admin_user.rb

class AdminUser < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, 
     :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me

  after_create { |admin| admin.send_reset_password_instructions }
    def password_required?
      new_record? ? false : super
    end


    before_destroy :raise_if_last
     def raise_if_last
      if AdminUser.count < 2
        raise "Can't delete last admin user"
      end
    end

end

config/environments/development.rb

..........
 #Added per active admin install instructions
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
banditKing
  • 9,405
  • 28
  • 100
  • 157

1 Answers1

2

sending email from localhost don't work directly if you haven't configured sendmail like utility.

you can either use SMTP for sending emails

check question below

send email from localhost

or you can write emails to a file

Rails Mailer: sending emails to a local file

Community
  • 1
  • 1
Loken Makwana
  • 3,788
  • 2
  • 21
  • 14