Note that there are some explanatory texts on larger screens.

plurals
  1. PO<Ruby on Rails> Routes
    primarykey
    data
    text
    <p>I'm a beginner in ruby on rails and was following an online tutorial. I got lost immediately on routes. Every time I try to go to my url 'pages/help' an error is displaying in the browser "<strong>The action 'show' could not be found for PagesController</strong>". I have a ruby partitions named _header that contains these codes:</p> <pre><code>&lt;header&gt; &lt;%= link_to logo, root_path %&gt; &lt;ul class="nav nav-tabs"&gt; &lt;li class="active"&gt; &lt;%= link_to "Home |", root_path %&gt; &lt;/li&gt; &lt;li&gt;&lt;%= link_to "Help |", pages_help_path %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= link_to "Sign In", '#'%&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/header&gt; </code></pre> <p>And when I try to click the "Help" link the error occurs.</p> <p>My routes.rb contains just these codes:</p> <pre><code>BakeShop::Application.routes.draw do resources :pages root :to =&gt; 'pages#home' #match '/help', :to =&gt; 'pages#help' get "pages/help" end </code></pre> <p>and i have a PagesController with only these codes:</p> <pre><code>class PagesController &lt; ApplicationController def home end def help end end </code></pre> <p>and when I run 'rake routes' the lists contained are:</p> <pre><code> pages GET /pages(.:format) pages#index POST /pages(.:format) pages#create new_page GET /pages/new(.:format) pages#new edit_page GET /pages/:id/edit(.:format) pages#edit page GET /pages/:id(.:format) pages#show PATCH /pages/:id(.:format) pages#update PUT /pages/:id(.:format) pages#update DELETE /pages/:id(.:format) pages#destroy root GET / pages#home pages_help GET /pages/help(.:format) pages#help </code></pre> <p>And I certainly have home.html.erb and help.html.erb created in my views folder. And the twist is that when I create a 'show.html.erb' in my views folder and create an action in my pages controller named 'show', the error disappears and links to . </p> <p>So what I'm saying is, can anyone explain this? Why is rails looking for 'show' action, and not 'help' action, that I didn't define</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload