On 9 March 2012 18:29, Roger Patrick <li...@ruby-forum.com> 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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to