For those of you who actually have, or actually are watching RailsCasts, and for those of you who have actually watched these two videos: http://railscasts.com/episodes/250-authentication-from-scratch?view=comments http://railscasts.com/episodes/250-authentication-from-scratch-revised
you will notice that in both of them, on every login blank test he does, Ryan Bates doesn't seem to bother about the fact that upon login validation_presence error, he gets redirected from /sessions/new to /sessions. This has bothered me, and I am still in big trouble finding the solution to this? I have a feeling that it's fairly simple, but I guess it's only hidden someplace visible, but not to me.
*THIS IS BASICALLY RYAN BATES CODE:*He's got the error - I've got the error.: IDEAS???
USER MODEL:
has_secure_password
attr_accessible :email, :password, :password_confirmation
validates_uniqueness_of :email
SESSIONS CONTROLLER:
def new
end
def create
user = User.find_by_email(params[:email])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
redirect_to root_url, notice: "Logged in!"
else
flash.now.alert = "Email or password is invalid"
render "new"
end
end
def destroy
session[:user_id] = nil
redirect_to root_url, notice: "Logged out!"
end
SESSIONS LOGIN PAGE:
<h1>Log In</h1>
<%= form_tag sessions_path do %>
<div class="field">
<%= label_tag :email %><br />
<%= text_field_tag :email, params[:email] %>
</div>
<div class="field">
<%= label_tag :password %><br />
<%= password_field_tag :password %>
</div>
<div class="actions"><%= submit_tag "Log In" %></div>
<% end %>