Greetings, As my first web app with Rails I am creating an HR Tracking program. There are employee ''records'' that can have ''comments'' added to each record. I also assign each comment a category such as ''general note'', ''disciplinary action'', or ''job changes'' which I''ve set in my Comments table using the values either 0, 1, or 2. I can create the comments fine, but difficulty I am having is seperating the comments into different areas of the employee record page based on the category. So, for example, if I want to add a comment like ''Employee was promoted to manager'' and assign it a category of ''job changes'', I would then want that comment to display in a list below the heading ''Job Changes'' on that records ''show'' page just above the comment form. The best way I can think of is doing something like: <% if comment_type = 1 %> <% for comment in @record.comments %> <% end %> <% end %> but I can''t seem to get the syntax correct. Can anyone assist? Below is my code and layout. ------------------------------------------------------------------------------- APP/CONTROLLERS/RECORDS_CONTROLLER.RB def comment Record.find(params[:id]).comments.create(params[:comment]) flash[:notice] = "Added your comment." redirect_to :controller => "records", :action => "show", :id => params[:id] end ------------------------------------------------------------------------------- APP/VIEWS/RECORD/SHOW.RHTML <fieldset><legend>Job Change Comments</legend> <% for comment in @record.comments %> <span class="smaller">Submitted: <%= comment.created_at %></span><br /><%=h comment.body %><hr> <% end %> <fieldset><legend>Add a Comment</legend> <%= form_tag :action => "comment", :id => @record %> <%= text_area "comment", "body", "cols" => 40, "rows" => 5 %><br/> <label for="record_comment_type">Comment Type</label><br/> <%= select( :comment, :comment_type, [[''General'', 0], [ ''Disciplinary'', 1],[''Job Change'', 2]]) %><br/> <br /> <%= submit_tag "Save" %> </fieldset> ------------------------------------------------------------------------------- COMMENTS TABLE STRUCTURE id (int) body (text) created_at (datetime) comment_type (int) record_id (int) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---