Confused by step #10


Step 10 has the following instructions but I have absolutely no idea what I need to do - can anyone offer guidance? I added spaces in the html code to stop the li/ul from screwing the formatting.

(project link:

Set up the posts#index controller action to handle GET requests:

  1. In the Posts controller, make an action named index:
    def index @new_post = @all_posts = Post.order(created_at: :desc).all end
    We'll use @new_post in the view to render a form.
    We'll use @all_posts to render a list of all posts, sorted in descending order.

  2. In app/views/posts/index.html, create a Rails form with the fields of the @new_post object to post comments.

  3. Replace the hardcoded < ul> element by using @all_posts:
    < ul class="comments"> <% @all_posts.each do |p| %> < li><%= p.comment %>

  4. <% end %>
    Here we loop through each element in @all_posts and display it in an < li> element.

For the first step, I have this:
class PostsController < ApplicationController
resources :posts
def inded
@new_post =
@all/posts = Post.order(created_at: :desc).all

But from there I am lost


Hi @kuwantum,

Please read this topic for information on how to format your code so it displays properly.

In the next step of that exercise, you need to open up the file config/routes.rb and set a root action:

root 'comments#index'

Then, after that, run the command given in the exercise in the terminal window (the black area below the code editor).


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.