Hi There, I''m looking to improve my search results by allowing a thumbnail of returned users to be displayed, I currently have a table that shows: <th> thumbnail here </th> <th>Last Name <th>Gender</th> <th>Location</ th> <th>Preference</th> what i''d like is to be able to add the user''s thumbnail to it. So far I have my search results page: <td><%= user.info.lastname %></td> <td><%= user.info.location %></td> <td><%= user.info.pref %></td> I tried to add the following: <% @user.friends.each do |friend| %> <%= link_to thumbnail_tag(friend), profile_for(friend) %> <% end %> Unfortunately, this returns with: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.friends I know it''s to do with the <% @user.friends.each do |friend| %> line, but i can''t seem to overcome this, despite an evening of google searches. Can anyone help? 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.
2009/12/2 RubyonRails_newbie <craigwesty79-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>:> Hi There, > > I''m looking to improve my search results by allowing a thumbnail of > returned users to be displayed, > > I currently have a table that shows: > > <th> thumbnail here </th> <th>Last Name <th>Gender</th> <th>Location</ > th> <th>Preference</th> > > what i''d like is to be able to add the user''s thumbnail to it. > > So far I have my search results page: > > <td><%= user.info.lastname %></td> > <td><%= user.info.location %></td> > <td><%= user.info.pref %></td> > > I tried to add the following: > <% @user.friends.each do |friend| %> > > <%= link_to thumbnail_tag(friend), profile_for(friend) %> > > <% end %> > > Unfortunately, this returns with: > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.friendsThat suggests that @user is nil. I notice that above you have user not @user Colin> > I know it''s to do with the <% @user.friends.each do |friend| %> line, > but i can''t seem to overcome this, despite an evening of google > searches. > > Can anyone help? > > > 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. > > >-- 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.
On Wed, Dec 2, 2009 at 7:04 PM, RubyonRails_newbie <craigwesty79-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi There, > > I''m looking to improve my search results by allowing a thumbnail of > returned users to be displayed, > > I currently have a table that shows: > > <th> thumbnail here </th> <th>Last Name <th>Gender</th> <th>Location</ > th> <th>Preference</th> > > what i''d like is to be able to add the user''s thumbnail to it. > > So far I have my search results page: > > <td><%= user.info.lastname %></td> > <td><%= user.info.location %></td> > <td><%= user.info.pref %></td> > > I tried to add the following: > <% @user.friends.each do |friend| %> > > <%= link_to thumbnail_tag(friend), profile_for(friend) %> > > <% end %> > > Unfortunately, this returns with: > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.friends > > I know it''s to do with the <% @user.friends.each do |friend| %> line, > but i can''t seem to overcome this, despite an evening of google > searches. > > Can anyone help?Hopefully. You''re referencing user.info.lastname, user.info.location, user.info.pref and @user.friends. Note the @, that makes reference to an instance variable which might not exist. you''d probalby wanted to say user.friends there.> > thanks :-)NP. -- Leonardo Mateo. There''s no place like ~ -- 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.
hi, Thanks for the replies... I tried user.friends, and nothing happened. Well, i didn''t get an image anyway. How would i need to combine the user.friends line witht he actual path to the image: <%= link_to thumbnail_tag(friend), profile_for(friend) %>? cheers On 2 Dec, 22:16, Leonardo Mateo <leonardoma...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Dec 2, 2009 at 7:04 PM, RubyonRails_newbie > > > > <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > Hi There, > > > I''m looking to improve my search results by allowing a thumbnail of > > returned users to be displayed, > > > I currently have a table that shows: > > > <th> thumbnail here </th> <th>Last Name <th>Gender</th> <th>Location</ > > th> <th>Preference</th> > > > what i''d like is to be able to add the user''s thumbnail to it. > > > So far I have my search results page: > > > <td><%= user.info.lastname %></td> > > <td><%= user.info.location %></td> > > <td><%= user.info.pref %></td> > > > I tried to add the following: > > <% @user.friends.each do |friend| %> > > > <%= link_to thumbnail_tag(friend), profile_for(friend) %> > > > <% end %> > > > Unfortunately, this returns with: > > You have a nil object when you didn''t expect it! > > The error occurred while evaluating nil.friends > > > I know it''s to do with the <% @user.friends.each do |friend| %> line, > > but i can''t seem to overcome this, despite an evening of google > > searches. > > > Can anyone help? > > Hopefully. > You''re referencing user.info.lastname, user.info.location, > user.info.pref and @user.friends. Note the @, that makes reference to > an instance variable which might not exist. you''d probalby wanted to > say user.friends there. > > > > > thanks :-) > > NP. > > -- > Leonardo Mateo. > There''s no place like ~- 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.
On Thu, Dec 3, 2009 at 5:56 AM, RubyonRails_newbie <craigwesty79-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> hi, > > Thanks for the replies... > > I tried user.friends, and nothing happened. Well, i didn''t get an > image anyway. > > How would i need to combine the user.friends line witht he actual path > to the image: <%= link_to thumbnail_tag(friend), profile_for(friend) > %>? >Well... that depends on what are you using those files, I would strongly recommend using paperclip or attachment_fu. If you''re uploading/handling your files by hand, you should be the one who knows where your files are stored and you''ll be responsible for building the image path. -- Leonardo Mateo. There''s no place like ~ -- 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.
Hello... +1 for paperclip or attachment_fu; they will make this a lot easier for you. Earlier this year I wrote a detailed tutorial on how to setup and use Paperclip in a new Rails application. Coincidentally, my example was to attach photos to users and then to show different size photos. At the bottom, I explain how to display a thumbnail for each user in a table, similar to what you''re trying to do. See: http://patshaughnessy.net/2009/4/30/paperclip-sample-app - pat On Dec 3, 8:41 am, Leonardo Mateo <leonardoma...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Dec 3, 2009 at 5:56 AM, RubyonRails_newbie<craigwest...@googlemail.com> wrote: > > hi, > > > Thanks for the replies... > > > I tried user.friends, and nothing happened. Well, i didn''t get an > > image anyway. > > > How would i need to combine the user.friends line witht he actual path > > to the image: <%= link_to thumbnail_tag(friend), profile_for(friend) > > %>? > > Well... that depends on what are you using those files, I would > strongly recommend using paperclip or attachment_fu. > If you''re uploading/handling your files by hand, you should be the one > who knows where your files are stored and you''ll be responsible for > building the image path. > > -- > Leonardo Mateo. > There''s no place like ~-- 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.