mardi 3 mars 2015

NoMethodError in UserController#new

I keep getting the following error on my app from 7.2.1 on Michael Hartl Ruby Rails tutorial. For some reason it is not accepting a nil @user field in the signup form.



undefined method `users_path' for #<#<Class:0x007ff87141aef8>:0x007ff870cf0d30>


new.html.erb



<% provide(:title, "Sign up") %>
<h1>Sign up</h1>

<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(@user) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>

<%= f.label :email %>
<%= f.email_field :email %>

<%= f.label :password %>
<%= f.password_field :password %>

<%= f.label :password_confirmation, "Confirmation" %>
<%= f.password_field :password_confirmation %>

<%= f.submit "Create my account", class: "btn btn-primary" %>
<% end %>
</div>
</div>


User_controller.rb



class UserController < ApplicationController

def new
@user = User.new
end

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

end


Routes.rb



Rails.application.routes.draw do

resources :user

get 'user/new'

root 'static_pages#home'

get 'help' => 'static_pages#help'

get 'about' => 'static_pages#about'

get 'contact' => 'static_pages#contact'

get 'signup' => 'user#new'

Aucun commentaire:

Enregistrer un commentaire