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

Don Neethling
Don Neethling
6,164 Points

RUBY path helper

The following works

index.html.erb
<h1>this is the neo blog</h1>
<% @pages.each do |blog|%>
    <p><%=link_to blog.title, blog_path(blog)%> </p>
<% end %>
routes.rb
Rails.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  get 'pages', to: 'pages#index'
  get '/pages/:id', to: 'pages#show', as: 'blog'

end

HOWEVER... The following does not work

index.html.erb
<h1>this is the neo blog</h1>
<% @pages.each do |blog|%>
    <p><%=link_to blog.title, blog%> </p>
<% end %>
routes.rb
Rails.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  get 'pages', to: 'pages#index'
  get '/pages/:id', to: 'pages#show', as: 'blog'

end

and results in the following error

undefined method `page_path' for #<#<Class:0x007fd871ac84a0>:0x007fd86dd15630> Did you mean? pages_path image_path

I would love to know what I am doing wrong and gain some understanding into the workings of path helpers

[MOD: edited code blocks - srh]