我正在尝试使用Devise启动并运行一个简单的Ruby / Rails应用程序。我已经按照几个设计指南进行操作,并且已经到了我的主页在localhost上显示的位置。我有两个链接,登录并注册。但是,当我点击其中任何一个时,它只是重新显示主页,即使URL在新页面上显示它。我认为这可能是一个路由问题,但我不知道该怎么做,因为我相信Devise会为我处理这个问题。当我“耙路线”时,我得到:
Francis@RYAN-PC ~/Documents/SCHOOL STUFF/USF - Super Senior Year/Senior Project/logintest
$ rake routes
home_index GET /home/index(.:format) home#index
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
root / home#index
从我看过的截图中,这有点不对劲。例如,对于'new_user_session'路线,路线应该类似于{:action=>"new", :controller=>"devise/sessions"}
。这可能只是说同一件事的不同方式,但我不确定。我唯一能想到的是我没有提供处理这些路由的代码,所以它只是默认重新显示同一个网页。但是,我认为Devise处理所有这些。我正在运行rails 3.2.11和Devise 2.0.0('gem list'表示我也有Devise 1.1.rc0)。我希望这是一个简单的误解和修复,但如果有人能提供帮助,那就太好了。谢谢。
编辑3/6/13 9:24 AM :删除了设计1.1.rc0并重新启动了rails服务器。似乎没有做任何事情。这是我的路线文件(带有注释):
LoginTest::Application.routes.draw do
get "home/index"
devise_for :users
root :to => 'home#index'
end
编辑3/6/13 2:27 PM :当我打开localhost的新标签然后点击注册时,这是我的开发日志:
编辑3/6/13 9:58 PM :更新日志以反映我的路线错误。功能(或缺乏功能)没有改变。
Started GET "/" for 127.0.0.1 at 2013-03-06 21:55:58 -0500
Processing by HomeController#index as HTML
Rendered home/index.html.erb within layouts/application (0.0ms)
Completed 200 OK in 34ms (Views: 34.0ms | ActiveRecord: 0.0ms)
Started GET "/assets/home.css?body=1" for 127.0.0.1 at 2013-03-06 21:55:59 -0500
Served asset /home.css - 304 Not Modified (0ms)
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-03-06 21:55:59 -0500
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-03-06 21:55:59 -0500
Served asset /application.css - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-03-06 21:55:59 -0500
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-03-06 21:55:59 -0500
Served asset /application.js - 304 Not Modified (6ms)
Started GET "/assets/home.js?body=1" for 127.0.0.1 at 2013-03-06 21:55:59 -0500
Served asset /home.js - 304 Not Modified (0ms)
Started GET "/users/sign_up" for 127.0.0.1 at 2013-03-06 21:56:01 -0500
Processing by Devise::RegistrationsController#new as HTML
Rendered c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/devise-2.2.3/app/views/devise/shared/_links.erb (1.0ms)
Rendered c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/devise-2.2.3/app/views/devise/registrations/new.html.erb within layouts/application (16.0ms)
Completed 200 OK in 65ms (Views: 64.0ms | ActiveRecord: 0.0ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-03-06 21:56:01 -0500
Served asset /application.css - 304 Not Modified (0ms)
Started GET "/assets/home.css?body=1" for 127.0.0.1 at 2013-03-06 21:56:01 -0500
Served asset /home.css - 304 Not Modified (0ms)
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-03-06 21:56:02 -0500
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/assets/home.js?body=1" for 127.0.0.1 at 2013-03-06 21:56:02 -0500
Served asset /home.js - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-03-06 21:56:02 -0500
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-03-06 21:56:02 -0500
Served asset /application.js - 304 Not Modified (2ms)
感谢大家的帮助。希望这个日志可以提供帮助。
编辑3/6/13 10:13 PM :刚才发现我现在已经设计了2.2.3和2.0.0。功能没有改变。
编辑3/7/13 3:08 PM :还是没想出来。有什么想法吗?
答案 0 :(得分:3)
好的,我明白了。我的<%yield%>
行没有=
来显示代码。现在它确实显示了。谢谢大家的时间。