INVITATION BETA EMAIL
I have in the email that the app send to friend’s email address
You are invited to ExampleApp.com click below to signup
http://localhost:3000/signup.efweiuvwnjernfwkefwebhsohj
But I have a dot in the url beteween http://localhost:3000 and the token
I wish the following url
http://localhost:3000/signup/efweiuvwnjernfwkefwebhsohj
config/routes.rb
match ‘/signup/:invitation_token’, :to => ‘users#new’
TO HAVE MORE INFORMATION TAKE A LOOK IN THE FOLLOW SCRIPT
#app/models/invitation.rb #how generate the token
class Invitation < ActiveRecord::Base
belongs_to :sender, :class_name => ‘User’
has_one :recipient, :class_name => ‘User’
email_regex = /\A[\w+-.]+@[a-z\d-.]+.[a-z]+\z/i
validates :recipient_email, :presence => true,
:format => { :with => email_regex }
before_create :generate_token
private
def generate_token
self.token = Digest::SHA1.hexdigest([Time.now, rand].join)
end
end
#/mailers/invitation.text.rb
You are invited to ExampleApp.com click below to signup
<%= @signup_url %>
models/mailer.rb
class Invitation < ActionMailer::Base
default :from => “removed_email_address@domain.invalid”
def invitation(invitation, signup_url)
@signup_url = signup_url
@invitation = invitation
mail(:to => invitation.recipient_email, :subject => “”)
end
/app/controllers/invitations_controller.rb
def create
@invitation = Invitation.new(params[:invitation])
respond_to do |format|
if @invitation.save
Mailer.invitation(@invitation,
signup_url(@invitation.token)).deliver
format.html { redirect_to(@invitation, :notice => ‘Invitation
was successfully created.’) }
format.xml { render :xml => @invitation, :status => :created,
:location => @invitation }
redirect_to root_url
else
format.html { render :action => “new” }
format.xml { render :xml => @invitation.errors, :status =>
:unprocessable_entity }
end
end
end
I BELIEVE IS A LITTLE PROBLEM BUT I DON’T UNDERSTAND WHERE IS MY MISTAKE
Thanks for read my post
bye,
C