this should simple fix, i've been unable find answer. can point me in right direction?
i'm implementing rails3 beta invite system la ryan bates - http://railscasts.com/episodes/124-beta-invitations
i've set mailer send out invite urls. works fine, apart 1 small issue.
the url generated mailer /user/sign_up.token.
i need generate /user/sign_up/token (slash instead of period).
i guess need change syntax in "mailer.invitation().deliver", can't find documentation help. can point me in right direction?
the relevant bits of routes file:
devise_for :users, :path_prefix => 'registration', :controllers => {:registrations => 'users/registrations'} "registration/users/sign_up/:invitation_token" => "users/registrations#new" end
invitations controller:
class invitationscontroller < applicationcontroller def new @invitation = invitation.new @title = "invite friend" end def create @invitation = invitation.new(params[:invitation]) @invitation.sender = current_user if @invitation.save if user_signed_in? mailer.invitation(@invitation, new_user_registration_path(@invitation.token)).deliver redirect_to root_url, :notice => "thank you, friend receive invitation soon." else redirect_to root_url, :notice => "thank you, we'll let know when next batch of invites availale." end else if current_user.invitation_limit > 0 render :action => 'new', :alert => "sorry, there problem! please try again." else redirect_to root_url, :alert => "sorry, don't have invitations left. please wait until issue more." end end end end
mailer:
class mailer < actionmailer::base def invitation(invitation, sign_up) subject 'invitation' recipients invitation.recipient_email @greeting = "hi" @invitation = invitation @signup_url = sign_up @sender = invitation.sender_id invitation.update_attribute(:send_at, time.now) end end
thank ideas!
not sure if work, maybe try
new_user_registration_url(@invitation.token)
instead of new_user_registration_path.
another (but not good) method be
new_user_registration_url+"/#{@invitation.token}" #substitute path url maybe
hope helps!
Comments
Post a Comment