Reputation:
I'm currently testing my Devise implementation - all is working well except for my Sign Up form.
Flash message error:
Invalid email or password.
I'm then directed to the Sign In form.
Not sure where I'm going wrong.
Sign Up form:
<h2>Sign Up</h2>
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-vertical' }) do |f| %>
<%= f.error_notification %>
<%= f.input :name, :autofocus => true %>
<%= f.input :email, :required => true %>
<%= f.input :password, :required => true %>
<%= f.input :password_confirmation, :required => true %>
<%= f.button :submit, 'Sign up', :class => 'button' %>
<% end %>
<% render 'devise/shared/links' %>
Routes:
authenticated :user do
root :to => 'home#index'
end
devise_for :users
resources :users
root :to => 'home#index'
resources :songs
get 'home/index'
match 'home/about', :to => 'home#about'
match 'home/contact', :to => 'home#contact'
Rails Server:
Started POST "/users/sign_in" for 127.0.0.1 at 2013-03-01 16:42:47 +1000
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"DxwF+dMC//5UIX5beKhzaBLjnB2xaJe7pQb/C3xNK1k=", "user"=>{"name"=>"test", "email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
Completed 401 Unauthorized in 2ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"DxwF+dMC//5UIX5beKhzaBLjnB2xaJe7pQb/C3xNK1k=", "user"=>{"name"=>"test", "email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
Rendered /Users/thmsmxwll/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.2.3/app/views/devise/shared/_links.erb (0.4ms)
Rendered devise/sessions/new.html.erb within layouts/application (7.5ms)
Rendered layouts/_navigation.html.erb (0.5ms)
Rendered layouts/_messages.html.erb (0.1ms)
Rendered layouts/_footer.html.erb (0.0ms)
Completed 200 OK in 104ms (Views: 19.1ms | ActiveRecord: 0.0ms)
Upvotes: 0
Views: 1327
Reputation: 23356
You have wrong registration path.
You are doing registration but the processing by your rails server is:
Processing by Devise::SessionsController#create as HTML
The above line indicates that the devise is somehow trying to create login session for the user but not the registration.
So rails is looking for row with email" = '[email protected]
which is yet not there in your database because that you are registering.
Upvotes: 0
Reputation: 8065
This is due to wrong url in form helper, just replace it by,
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |f| %>
for sign up, url need to be registration_path not session_path.
Upvotes: 1