Reputation: 5
Whats wrong in my authentication i also dont know..can someone tell me what wrong? i got user scaffold, and this is my admin controller
class AdminController < ApplicationController
def login
if request.post?
user = User.authenticate(params[:name], params[:password])
if user
session[:user_id] = user.id
redirect_to(:action => "index")
else
flash.now[:notice] = "Invalid user/password combination"
end
end
end
def logout
session[:user_id] = nil
flash[:notice] = "Logged out"
redirect_to(:action => "login")
end
def index
end
end
and this is my admin/login.html.erb
<div>
<%= form_tag do %>
<fieldset>
<legend>Please Log In</legend>
<div>
<label for="name">Name:</label>
<%= text_field_tag :name, params[:name] %>
</div>
<div>
<label for="password">Password:</label>
<%= password_field_tag :password, params[:password] %>
</div>
<div>
<%= submit_tag "Login" %>
</div>
</fieldset>
<% end %>
</div>
but when i try to log in using existence user it come like this
No route matches "/admin/login"
whats wrong with my code??am i missing something?
Upvotes: 0
Views: 732
Reputation: 1401
You should do that
Hawary::Application.routes.draw do
post 'admin/login' => 'admin#login'
end
Upvotes: 2