Railsのチュートリアルを開始しましたが、認証用のデバイスgemを使用して別のプロジェクトをセットアップしようとしています。基本的に私が欲しいのは、ホームページ、ユーザーが基本的にサインアップするためのフォームに記入できるページ、そして認証を行う安全なページを用意することです。
現在、サインアップページに移動すると問題が発生します。これが私が受け取っているエラーです:
NoMethodError in Signup#index
Showing /Users/tomcaflisch/Sites/project2/app/views/signup/_form.html.erb where line #1 raised:
undefined method `users_path' for #<#<Class:0x007fa734b3e510>:0x007fa734b3a910>
Extracted source (around line #1):
1: <%= form_for(@user) do |f| %>
2: <% if @user.errors.any? %>
3: <div id="errorExplanation">
4: <h2><%= pluralize(@user.errors.count, "error") %> prohibited this post from being saved: </h2>
signup_controller.rb:
class SignupController < ApplicationController
def index
@user = User.new
end
def new
@user = User.new
respond_to do |format|
format.html
end
end
end
user.rbモデル:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :username
end
../views/signup_form.html.erb:
<%= form_for(@user) do |f| %>
<% if @user.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this post from being saved: </h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<div class="field">
<%= f.label :username %><br />
<%= f.text_field :username %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.text_field :password %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
ルート.rb:
get "signup/index"
devise_for :users
get "index/index"
root :to => 'index#index'
$ bundleexecrakeルート| grepユーザー:
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET /users/cancel(.:format) {:action=>"cancel", :controller=>"devise/registrations"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}