You need to take the redirect_to out of the about_us action, and instead
just set an instance variable that has the comments that you want to
display.

# app/controllers/pages_controller.rb

class Pages < ApplicationController
  def about_us
    @comments = Comment.all
  end
end



Then all you need to do is render the comments page.

# app/views/pages/about_us.html.erb

<%= render 'comments/index' %>



# app/views/comments/index.html.erb

<%= for comment in @comments %>
 ...


However, really you should put the part of the comments/index.html.erb
that is shared with about_us.html.erb into a partial, so that both views
can use the same code.

# app/views/comments/_all_comments.html.erb

<%= for comment in comments %>
  ...

'comments' is a local variable here, so you need to define this variable
when you call the 'render' method.


# app/views/pages/about_us.html.erb

<%= render 'comments/all_comments', :comments => @comments %>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to