mardi 23 juin 2015

Ruby on Rails - Hartl Tutorial Chapter 7 - The action 'index' could not be found for UsersController

I'm new to Ruby on Rails so I'm following Michael Hartl's Ruby on Rails Tutorial and I'm running across an issue.

In Chapter 7 Section 1 you are supposed to be showing User pages but I am running into this error:

"The action 'index' could not be found for UsersController"

when I try to go to "localhost:3000/users"

I'm not sure what all information I would need to include so here is some and please let me know if I need more. I'd greatly appreciate any help I can get. I did look up similar questions on here but none helped me with my issue.

Here is my routes.rb

Rails.application.routes.draw do
root              'static_pages#home'
  get 'help' =>     'static_pages#help'
  get 'about' =>    'static_pages#about'
  get 'contact' =>  'static_pages#contact'
  get 'signup' =>   'users#new'
resources :users
end

users_controller.rb

class UsersController < ApplicationController

  def show
    @user = User.find(params[:id])
  end

  def new
  end
end

show.html.erb

<%= @user.name %>, <%= @user.email %>

I've double checked my code against the tutorial and I can't seem to find any difference. The only issue I can think may be when it asked me to create the show.html.erb I just right clicked and hit "create file" in my online IDE (Cloud 9.io which the tutorial recommended). Hartl just says you have to create it by hand so I assume that is what he meant. Again, any help would be greatly appreciated. Thank you.

Aucun commentaire:

Enregistrer un commentaire