Hi, so I am trying to display the author''s name of comments. I am able to display the comments by iterating through the hash @comments = PhotoComment.find(:all, :conditions => { :photo_id => params[:photo_id] }), but I want to be able to display the name associated with the author of each comment. The iteration in my view looks like this: <% for comment in @comments -%> <br/>on <%= comment.created_at.strftime(''%m-%d-%Y'') %> @ <%= comment.created_at.strftime(''%I:%M'') %> BLANK said: <br/><%= white_list comment.comment %><br/> <% end -%> I would like to interchange the BLANK with the commentors name. Each PhotoComment object has a user_id field which stores the user id for the author of the comment. This name is stored in another table called users. How do I append this name into the @comments hash? Is this how you do it? or do you create another variable for the author names? 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > <% for comment in @comments -%> > <br/>on <%= comment.created_at.strftime(''%m-%d-%Y'') %> @ > <%= comment.created_at.strftime(''%I:%M'') %> BLANK said: > <br/><%= white_list comment.comment %><br/> > <% end -%> >ok, in model PhotoComment: belongs_to :user and then simply replace BLANG with: <%= comment.user.name %> (assuming, the users name is stored in name...) -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
that is absolutely amazing...thank you On Mar 6, 1:14 am, Thorsten Mueller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > <% for comment in @comments -%> > > <br/>on <%= comment.created_at.strftime(''%m-%d-%Y'') %> @ > > <%= comment.created_at.strftime(''%I:%M'') %> BLANK said: > > <br/><%= white_list comment.comment %><br/> > > <% end -%> > > ok, in model PhotoComment: > > belongs_to :user > > and then simply replace BLANG with: > <%= comment.user.name %> > > (assuming, the users name is stored in name...) > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---