Ruby on Rails Monday, July 10, 2017

Seeing your routes, try root_path or articles_path. 

On Jul 10, 2017, at 3:36 PM, Ralph Shnelvar <> wrote:

What generates articles_index_path ? I am porting some Rails 4 code to Rails 5 and I hit the following problem when using  Rspec:  articles_index_path  is undefined.

Rails.application.routes.draw do
 devise_for :users
 root 'static_pages#root'
 resources :users

 resources :articles
 root to: "articles#index"
 # byebug

In /home/real-estate-data-mining/spec/requests/article_spec.rb I have
require 'rails_helper'
RSpec.describe "Article", type: :request do
 describe "GET /article" do
   it "works! (now write some real specs)" do
     # get article_index_path
     get articles_index_path
     expect(response).to have_http_status(200)

When I examine the code environment around the byebug I see
[3, 12] in /home/real-estate-data-mining/spec/requests/article_spec.rb
   3: RSpec.describe "Article", type: :request do
   4:   describe "GET /article" do
   5:     it "works! (now write some real specs)" do
   6:       byebug
   7:       # get article_index_path
=>  8:       get articles_index_path
   9:       expect(response).to have_http_status(200)
  10:     end
  11:   end
  12: end
(byebug) articles_path
(byebug) articles_index_path
*** NameError Exception: undefined local variable or method `articles_index_path' for #<RSpec::ExampleGroups::Article_2::GETArticle:0x00563031a8a0e0>

(byebug) article_index_path
*** NameError Exception: undefined local variable or method `article_index_path' for #<RSpec::ExampleGroups::Article_2::GETArticle:0x00563031a8a0e0>


This must be a common software pattern in Rails but, damn, I have Googled for what feels like a googol (it's not a typo) hours without success trying to find what metaprogramming code would generate articles_index_path .  

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment