Acts_as_Inviteable The plugin does not send invitations to Ruby on Rails

I am trying to create beta invitations that every existing user can send, and was hoping to be able to use a plugin called acts_as_inviteable http://github.com/brianjlandau/acts_as_inviteable

I was wondering if anyone has direct experience. When I checked the console, it seems to be generating the correct requests, but no errors via email or email are raised.

I am tempted to just use the excellent Ryan Bates tutorial on beta invitations and write it myself, but I would like something to work. We just can't figure it out.

+4
source share
1 answer

Here it is necessary to eliminate a number of problems:

Add this line to one of your configuration blocks (either in environment.rb , or in each of the files in config/environment ):

 config.action_mailer.default_url_options = {:host => 'somewhere.com'} 

In app/models/invitation.rb on line 3, you call attr_accessible :recipient_email , this will prevent the mass assignment of the sender. You should change it to this:

 attr_accessible :recipient_email, :sender, :sender_id 

Also invitations_controller.rb should look like this:

 class InvitationsController < ApplicationController before_filter :require_analyst def new @invitation = Invitation.new end def create @invitation = Invitation.new(params[:invitation]) @invitation.sender = current_analyst if @invitation.save flash[:notice] = "Thank you, invitation sent." redirect_to root_url else render :action => 'new' end end end 

You really cannot send an invitation if you are not logged in (because you need a sender, which in this case is current_analyst not @current_user ), so strings with different logic depend on whether or not.

In addition, the letter will be automatically sent using the invitation model, so the call to Mailer.deliver_invitation(@invitation, signup_url(@invitation.token)) not needed (and in fact it should be AnalystInvitationMailer.deliver_invitation(@invitation) )

Here you can see the full working patch: http://gist.github.com/290911

+2
source

All Articles