2

I am trying to get a simple Ruby/Rails application with Devise up and running. I have followed several devise guides and have gotten to the point where my homepage displays on localhost. I have two links, sign in and sign up. However, when I click on either of them, it just re-displays the homepage, even though the URL says its on the new page. I think it might be a routing problem, but I don't know what to do since I believe Devise handles that for me. When I do 'rake routes' I get:

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

From the screenshots I've seen, there is something wrong with this. For the 'new_user_session' route, for instance, the route should be something like {:action=>"new", :controller=>"devise/sessions"}. This could just be a different way of saying the same thing, but I'm not sure. The only other thing I could think of is I didn't supply the code for handling each of these routes, so it's just re-displaying the same webpage by default. However, I thought Devise handles all of that. I am running rails 3.2.11 and Devise 2.0.0 ('gem list' says I have Devise 1.1.rc0 also). I hope this is a simple misunderstanding and fix, but if anyone could help, that would be great. Thank you.

EDIT 3/6/13 9:24AM: Removed devise 1.1.rc0 and restarted rails server. Appears to have done nothing. Here is my routes file (with comments taken out):

LoginTest::Application.routes.draw do
get "home/index"

devise_for :users

root :to => 'home#index'
end

EDIT 3/6/13 2:27PM: Here is my development log when I open a fresh tab to localhost and then click on sign-up:

EDIT 3/6/13 9:58PM: Updated logs to reflect route bugs I had. Functionality (or lack thereof) hasn't changed.

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)

Thanks everyone for your help. Hopefully this log can help.

EDIT 3/6/13 10:13PM: Just figured out that I now have devise 2.2.3 along with 2.0.0. Functionality hasn't changed.

EDIT 3/7/13 3:08PM: Still haven't figured it out. Any ideas?

4

1 回答 1

3

好的,我想通了。我的<%yield%>行没有=显示代码。现在它确实显示了。谢谢大家的时间。

于 2013-03-07T21:17:42.673 回答