Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Rails Routes and Resources A Route to a Read Action Creating a Show View

Getting Error After Adding show.html.erb file to pages.

I'm getting a syntax error in PagesController#index after adding the show.html.erb to views.

It's giving the following code I have written as an error:

<% @pages.each do |page| %> <p><%= link_to page.title, page) %></p> <% end %>

I've looked it over several times and don't know what I'm doing wrong. Any ideas? The error occurs when I go to localhost:3000/pages. Everything else seems to work fine. When I put the id at the end of the url, the title and body shows up like it should.

1 Answer

Look at this again:

<%= link_to page.title, page) %>

You have a closing parenthesis but no opening one. This is why I'm kinda skeptical about Ruby's "parentheses are optional" language rule, it's easy to mess up. But in this case, either add or remove them and you should be good to go. Cheers.

Excellent catch Eric! Everything is working now. Thanks so much!