Hello everyone,
I am new to rails and I am having some trouble getting the Devise
authorization plugin working. I can get the login page to display, but
when I enter the credentials for a known user (I seeded an account to
the database) it just says “Invalid email or password,” even though
I’m 100% sure I entered the right information, and redirects me to the
login form. I’m thinking this might be a namespace problem or
something but I’m not sure.
Here is the relevant code:
— routes.rb —
Root
root :to => “content#index”
Admin Controllers
namespace ‘admin’ do
root :to => “admin#index”
AdminController
devise_for :admin, :path=> ‘’, :path_names => {:sign_in =>
‘login’, :sign_out => ‘logout’}
resources :admin
end
UsersController
devise_for :users, :path_names => {:sign_in => ‘login’, :sign_out =>
‘logout’}
— END routes.rb —
— admin.rb (Model) —
class Admin < ActiveRecord::Base
devise :database_authenticatable, :recoverable, :rememberable,
:trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :first_name,
:last_name, :superadmin
end
— END admin.rb —
— new.html.erb (The login form) —
<%= form_for(resource, :as => resource_name, :url =>
session_path(resource_name), :html => {:id => :admin_login_form}) do |
f| %>
<%= f.label :email %> |
<%= f.email_field :email %> |
<%= f.label :password %> |
<%= f.password_field :password %> |
<%= f.label :remember_me %> |
<%= f.check_box :remember_me %> |
<%= f.submit “Sign in” %>
<% end %>
<%= render :partial => “devise/shared/links” %>
— END new.html.erb —
Any help with this would be greatly appreciated!