Reputation: 567
I recently started following Hartl's Ruby on Rails tutorial.
I downloaded the existing sample_app_reference
app from bitbucket.
My goal is not to start and learn everything from scratch but rather to add new features to the already existing app.
The issue is that I can't test the features I'm adding since I can't activate my account locally. In order to activate my account, I need to receive an activation email (which I'm not). I've searched the web for hours, but couldn't find anything regarding the issue. Did anyone try this tutorial before and encountered the same problem? Any help would be much appreciated.
Upvotes: 0
Views: 258
Reputation: 6237
Yeah...sending emails from dev environment is often not straightforward. As Vasilisa comments above, the quickest fix for your need is to activate the user from the rails console...perhaps like this:
% bundle exec rails console
my-app(development)> User.last.activate
However, there will be other times when you actually want to see the email in the context of a mail client. For this, https://mailcatcher.me/ makes it super easy. Just install the mailcatcher gem -- not in your app's Gemfile, but on your local machine's ruby installation.
Then, change the host and port in app/config/development.rb
(NOT in other environemnts, like prod!)
config.action_mailer.smtp_settings = {
# For use with Mailcatcher: https://mailcatcher.me/
address: '127.0.0.1',
port: 1025
}
Run mailcatcher
once from a command prompt.
Then, do your thing in your app to trigger an email send, and open http://127.0.0.1:1080/
in your browser. Voila, you see your email like it was really sent.
This a super-easy, super-useful way to see real emails without setting up your local env to actually send emails.
Upvotes: 1