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 => "info-OiLJxWuRT67QT0dZR+AlfA@public.gmane.org" 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
the problem is here def create> @invitation = Invitation.new(params[:invitation]) > > respond_to do |format| > if @invitation.save > Mailer.invitation(@invitation, > signup_url(*:invitation_token=>*@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 > endtry it now -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Radhames Brito wrote in post #987907:> @invitation = Invitation.new(params[:invitation])> respond_to do |format| > if @invitation.save > Mailer.invitation(@invitation, > signup_url(*:invitation_token=>*@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 > endI simply substitute the follow line Mailer.invitation(@invitation,signup_url(@invitation.token)).deliver with this Mailer.invitation(@invitation,signup_url(@invitation.token)).deliver this is the result http://localhost:3000/signup?invitation_token=30220e3a8db1994bc7c672d55491991f8e2ebf1a I wish this http://localhost:3000/signup/30220e3a8db1994bc7c672d55491991f8e2ebf1a I''m searching in other forum and documentation on line ... when I will find the solution will put there ... bye, C ps. I don''t understand ''cause you put the ''*'' simbol -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > > I simply substitute the follow line > > Mailer.invitation(@invitation,signup_url(@invitation.token)).deliver > > with this > > Mailer.invitation(@invitation,signup_url(@invitation.token)).deliver > >try this , go to the console and type rails c, then type this r = ActionController::Routing::Routes then r.generate :controller => :invitations, :action => create , : invitation_token => "123" see if it generates what you want , then use Mailer.invitation(@invitation,url_for (:controller => :invitations, :action => create , : invitation_token => @invitation.token,:method => :post)).deliver -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Radhames Brito wrote in post #988052:>> > try this , go to the console and type rails c, then type this > > r = ActionController::Routing::Routes > > then > > r.generate :controller => :invitations, :action => create , : > invitation_token => "123" > > see if it generates what you want , then use > > Mailer.invitation(@invitation,url_for (:controller => :invitations, > :action > => create , : invitation_token => @invitation.token,:method => > :post)).deliverHey thank you ... for your answer the environment of rails c is Rails 3.0.1 and use your advices I receive only an error message after I insert your follow command:> r.generate :controller => :invitations, :action => create , : > invitation_token => "123"NameError: undefined local variable or method ´create'' for main:Object from (irb): 2 Anyway I will use your previous suggest It''s works to accept the invitation sign up but the signup url is like this: http://localhost:3000/signup?invitation_token=3022... thank you, C -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito
2011-Mar-18 22:06 UTC
Re: Re: Re: Beta Invitation in Rails 3, little problem
On Fri, Mar 18, 2011 at 5:01 PM, Cluter Vipic <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Radhames Brito wrote in post #988052: > >> > > try this , go to the console and type rails c, then type this > > > > r = ActionController::Routing::Routes > > > > then > > > > r.generate :controller => :invitations, :action => create , : > > invitation_token => "123" > > > > see if it generates what you want , then use > > > > Mailer.invitation(@invitation,url_for (:controller => :invitations, > > :action > > => create , : invitation_token => @invitation.token,:method => > > :post)).deliver > > Hey thank you ... for your answer the environment of rails c is Rails > 3.0.1 and use your advices I receive only an error message after I > insert your follow command: > > > r.generate :controller => :invitations, :action => create , : > > invitation_token => "123" > > NameError: undefined local variable or method ´create'' for main:Object > from (irb): 2 > >it appears that you are launching irb not rails console, to go to the rails console you have to type rails c at the app directory, then try mixing r.generate :controller => :invitations, :action => create , :invitation_token => "123" until you get what you want. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Radhames Brito wrote in post #988228:> On Fri, Mar 18, 2011 at 5:01 PM, Cluter Vipic <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> rails c > > at the app directory, then try mixing > > r.generate :controller => :invitations, :action => create , > :invitation_token => "123" > > until you get what you want.I tried same error>> NameError: undefined local variable or method create'' for main:Object >> from (irb): 2 >>I believed that the command "rails console" is the same "rails c" isn`t it? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito
2011-Mar-19 02:03 UTC
Re: Re: Re: Re: Beta Invitation in Rails 3, little problem
Yes it is. but i thought you may have mistakenly used irb instead of rails c -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.