我有一个没有问题的网站。这是路线文件:
Testpager::Application.routes.draw do
devise_for :users
resources :news, only: [:index, :show]
resources :documents, only: [:index, :show]
namespace :admin do
resources :documents, only: [:index, :show, :destroy, :edit, :update, :new, :create]
resources :news, only: [:index, :show, :destroy, :edit, :update, :new, :create]
get "admin" => 'documents#index'
end
get "contacts/index"
get "services/index"
get "index/index"
get "admin/index"
root 'index#index'
end
我想添加一个注册系统。要做到这一点,我正在使用Devise。
我的行动是:
rails g devise:install
将此添加到application.html.erb:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
跑rails g devisw User
rake db:migrate
rails server
http://localhost:3000/users/sign_up
我收到以下错误消息:
ActionController::UrlGenerationError in Devise::Registrations#new
Showing /home/kalinin/rails/testpager/app/views/shared/_nav_main.html.erb where line #6 raised:
No route matches {:action=>"index", :controller=>"devise/index"}
Extracted source (around line #6):
<ul>
<li>
<%= link_to 'index', controller: "index", action: "index" %>
</li>
Trace of template inclusion: app/views/layouts/application.html.erb
这是控制器:
class IndexController < ApplicationController
def index
end
end
IndexController的视图存在。
答案 0 :(得分:0)
查看此链接关于向设计注册添加自定义字段:http://jacopretorius.net/2014/03/adding-custom-fields-to-your-devise-user-model-in-rails-4.html。您需要做的是设置一个继承自Devise :: RegistrationsController的注册控制器。这个快速教程易于阅读和理解。