yev2000/myflix — pull request #9 by yev2000 (2014-11-18 06:17:45+00:00)
Title: Implementation of inviting users, along with use of Tokenable.

A few notes on the implementation in this pull request:

I started the process of using Tokenable in User and Invitation models before realizing that since I don't create the token for the user until an actual forget password request comes in, I can't use Tokenable as a before_create on the model. Therefore, I went through the trouble of renaming "password_reset_token" to "token" in my User model, in anticipation of the Tokenable use only to stop. So those changes to the field name are in the User code and associated tests even though I don't use Tokenable.

I did use Tokenable for the Invitation.

I chose to use InvitationController#show to handle the invitation token being followed by the user in order to create a new account. It still renders the users/new template, but it does not route to the users controller directly. I wanted	to get feedback on this approach I chose. You will see that in the routes file and in the InvitationController#show implementation.

I also chose to implement functionality such that if an invited user registers, all invitations targeting their email address are deleted. This is implemented when code in UsersController calls Invitation.delete_invitations_by_email at user creation time.

I implemented a "to_param" method in the Invitation model, so that the token is returned rather tahn ID: this made it easier to not have to over-ride for model-backed forms.

I use Figaro to manage the mailer settings and changed the production.rb configuration to refer to the mailgun-named environment variables that Heroku sets. My development.rb still points to Mailtrap.