0

I just inherited a rails project using devise. In production you can send a user a invitation with an invitation token. Does devise have a way to set up a dummy invitation token? In other words is there known way to deal with all of devises different authentication systems in a dev environment?

Thanks

bonum_cete
  • 4,730
  • 6
  • 32
  • 56
  • You can could create a user manually in the rails console – Aaron Dufall Oct 08 '13 at 15:09
  • You can create a user from the console: http://stackoverflow.com/questions/4316940/create-a-devise-user-from-ruby-console or you can use the registration form and the confirmation mail will be displayed in the debug output of your rails development server. – Mindbreaker Oct 08 '13 at 15:16

1 Answers1

2

In my development environment I turn email off. Then create new users, whether invitation guest users or standard users with the form - then check my logs for the email sent to user and grab the invitation link.

in `config/environments/development.rb' change:

 config.action_mailer.delivery_method = :smtp

to

config.action_mailer.delivery_method = :false

Then you can grab the email body from the logs and use the link.

You can always change the token if you need to.

User.resend_invitation!(:email => "joeblow@lalaland.com")

You can also work it from the command line side:

User.invite!(:email => "joeblow@lalaland.com", :name => "Joe Blow")

To skip the user email you can do:

User.invite!(:email => "joeblow@lalaland.com", :name => "Joe Blow") { |user| user.skip_invitation => true }

And to accept it from the command line:

u = User.find_by_email("joeblow@lalaland.com")
User.accept_invitation!(:invitation_token => u.invitation_token, :password => "ad97nwj3o2")
trh
  • 7,186
  • 2
  • 29
  • 41