Hi Everyone... I''m following a railscast episode on how to implement an invitation feature. It''s going really well, but i''ve hit a minor snag that I cant get over.. undefined method `generate_token'' for #<Invitation:0x2563bf8> The invite form allows me to check for a user, and whether they already have registered. If they have, the invitation is not sent, and a flash message is printed. If the email does not exist, the invite count (starts at 5) decrements until you have none left. When i click invite, i get the error above. It''s moaning about this line: @invitation.sender = @user i tied replacing @user with user, but still no use.. def create @invitation = Invitation.new(params[:invitation]) @invitation.sender = @user if @invitation.save flash[:notice] = "Thanks - Invitation sent successfully." redirect_to hub_url else render :action => ''new'' end end Any ideas why this wont decrement, and why this error is still visible? Many Thanks -- 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.
You should specify where @user is defined, otherwise it looks like an undefined variable issue. You haven''t defined @user in the code you pasted. Most authentication schemes define the current logged in user as "current_user" or "User.current". Are you defining it as @user? On Feb 9, 6:05 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi Everyone... > > I''m following a railscast episode on how to implement an invitation > feature. > > It''s going really well, but i''ve hit a minor snag that I cant get > over.. > > undefined method `generate_token'' for #<Invitation:0x2563bf8> > > The invite form allows me to check for a user, and whether they > already have registered. If they have, the invitation is not sent, and > a flash message is printed. > > If the email does not exist, the invite count (starts at 5) decrements > until you have none left. > > When i click invite, i get the error above. It''s moaning about this > line: @invitation.sender = @user > > i tied replacing @user with user, but still no use.. > > def create > @invitation = Invitation.new(params[:invitation]) > @invitation.sender = @user > if @invitation.save > flash[:notice] = "Thanks - Invitation sent successfully." > redirect_to hub_url > else > render :action => ''new'' > end > end > > Any ideas why this wont decrement, and why this error is still > visible? > > Many Thanks-- 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.
Ok - So should I have another line in that says: user = invitation.sender followed by @invitation.sender = @user ? Sorry - may be a daft question, but trying to get my head round it as I go. The tutorial has been trouble free until this... :-) On 10 Feb, 04:09, David <furb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You should specify where @user is defined, otherwise it looks like an > undefined variable issue. You haven''t defined @user in the code you > pasted. Most authentication schemes define the current logged in user > as "current_user" or "User.current". Are you defining it as @user? > > On Feb 9, 6:05 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > > > > Hi Everyone... > > > I''m following a railscast episode on how to implement an invitation > > feature. > > > It''s going really well, but i''ve hit a minor snag that I cant get > > over.. > > > undefined method `generate_token'' for #<Invitation:0x2563bf8> > > > The invite form allows me to check for a user, and whether they > > already have registered. If they have, the invitation is not sent, and > > a flash message is printed. > > > If the email does not exist, the invite count (starts at 5) decrements > > until you have none left. > > > When i click invite, i get the error above. It''s moaning about this > > line: @invitation.sender = @user > > > i tied replacing @user with user, but still no use.. > > > def create > > @invitation = Invitation.new(params[:invitation]) > > @invitation.sender = @user > > if @invitation.save > > flash[:notice] = "Thanks - Invitation sent successfully." > > redirect_to hub_url > > else > > render :action => ''new'' > > end > > end > > > Any ideas why this wont decrement, and why this error is still > > visible? > > > Many Thanks- Hide quoted text - > > - Show quoted text --- 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.