I have the ability to send email to a user if a certain user has requested interest in their product. In my email I want to include certain information that is pulled from users but at the moment I am getting errors because it states that they are undefined despite these lines being used elsewhere in my application. I shall copy the email below and anything between the <% %> is what I wish to include and was wondering if anyone could point me in the right direction and tell me which are those that are correct and are not. Any help would be wonderful. The message I want to send is as followed: Hello <%@user.username%> The user <% current_user.username %> has registered an interest in the following product of yours: <% @book.book_name %> <% @book.genre %> The user <% current_user.usernames %> has the following games for offer: <% current_user.book.book_name %> To view <% current_user.username %> profile click <% link_to "here", current_user.show %> If you wish to contact the user by email then contact the following email <% current_user.email %>. I hope that makes sense. In order to give further insight in to what I have, I have a users table that includes user information and a book table that has books information with a user_id foreign key. Users have a has_many with books and games belongs_to user. The @user lines work for me but I get undefined method for anything after @book e.g. undefined method ''book_name''. Why is this so when it works for user? Finally I have come to understand that the mailer doesn''t recognise current_user? how would I go about doing the current_user line if that line is not able to be used? -- 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 have the ability to send email to a user if a certain user has requested interest in their product. In my email I want to include certain information that is pulled from users but at the moment I am getting errors because it states that they are undefined despite these lines being used elsewhere in my application. I shall copy the email below and anything between the <% %> is what I wish to include and was wondering if anyone could point me in the right direction and tell me which are those that are correct and are not. Any help would be wonderful. The message I want to send is as followed: Hello <%@user.username%> The user <% current_user.username %> has registered an interest in the following product of yours: <% @book.book_name %> The user <% current_user.usernames %> has the following games for offer: <% current_user.book.book_name %> To view <% current_user.username %> profile click <% link_to "here", current_user.show %> If you wish to contact the user by email then contact the following email <% current_user.email %>. Below is my mailer class. I believe this is why it does not recognize the game command but I tried putting a similar line in as I had with user and it did not work. Any idess? My @user.username in the email works fine. class GameTrade < ActionMailer::Base default :from => "Roger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" def book_interest(user) @user = user mail :to => user.email, :subject => "book Interest" end end My final problem is that I have been lead to believe that current_user does not work in the email delivery, how would I go about adding such feature or is it not possible? -- 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.
On 9 March 2012 18:29, Roger Patrick <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have the ability to send email to a user if a certain user has > requested interest in their product. In my email I want to include > certain information that is pulled from users but at the moment I am > getting errors because it states that they are undefined despite these > lines being used elsewhere in my application. I shall copy the email > below and anything between the <% %> is what I wish to include and was > wondering if anyone could point me in the right direction and tell me > which are those that are correct and are not. Any help would be > wonderful. The message I want to send is as followed: > > Hello <%@user.username%> > > The user <% current_user.username %> has registered an interest in the > following product of yours: > > <% @book.book_name %> > <% @book.genre %> > > The user <% current_user.usernames %> has the following games for offer: > > <% current_user.book.book_name %> > > To view <% current_user.username %> profile click <% link_to "here", > current_user.show %> > If you wish to contact the user by email then contact the following > email <% current_user.email %>. > > > I hope that makes sense. In order to give further insight in to what I > have, I have a users table that includes user information and a book > table that has books information with a user_id foreign key. Users have > a has_many with books and games belongs_to user. > > The @user lines work for me but I get undefined method for anything > after @book e.g. undefined method ''book_name''. Why is this so when it > works for user?It is always a good idea to paste the exact error message in. What does it say the method is undefined for? If it says that is not defined for nil then that means that your @book is not a Book but is nil. Colin -- 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.
Maybe Matching Threads
- undefined local variable or method 'game'
- Action Controller Error: undefined local variable or method `current_user'
- How do I force link_to/form helpers to use the superclass name in the path instead subclass?
- syntax error, unexpected tSTRING_BEG
- Spring Cleaning