Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 802471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:36:29+00:00 2026-05-14T23:36:29+00:00

I’m trying to set up a simple login using AuthLogic into my User table.

  • 0

I’m trying to set up a simple login using AuthLogic into my User table. Every time I try, the login fails and I don’t know why. I’m sure this is a simple error but I’ve been hitting a brick wall with it for a while.

#user_sessions_controller
def create
@user_session = UserSession.new(params[:user_session])
  if @user_session.save
    flash[:notice] = "Login successful!"
  else
    flash[:notice] = "We couldn't log you in. Please try again!"
    redirect_to :controller => "index", :action => "index"
  end
end

#_user_login.html.erb (this is the partial from my index page where Users log in)
<% form_tag user_session_path do %>
  <p><label for="login">Login:</label> 
<%= text_field_tag "login", nil, :class => "inputBox", :id => "login",
  </p>

  <p><label for="password">Password: </label>
<%= password_field_tag "password", nil, :class => "inputBox", :id => "password",
  </p>

  <p><%= submit_tag "submit", :class => "submit" %></p>
<% end %>

I had Faker generate some data for my user table but I cannot log in! Every time I try it just redirects to index. Where am I going wrong? Thanks everybody.

——UPDATE——

I implemented Jakub Hampl’s suggestion with form_for just now – I’m getting a new error.

ActionView::TemplateError (called id for nil, which would mistakenly be 4 -
1: <% form_for @user_session do |f| %>
2: <% if flash[:notice] -%>
3: <p class="notice"><%= flash[:notice] %></p>
4: <% end -%>

app/views/index/_user_login.html.erb:1
app/views/layouts/index.html.erb:65
app/controllers/index_controller.rb:3:in `index'

Rendered rescues/_trace (86.0ms)
Rendered rescues/_request_and_response (1.0ms)
Rendering rescues/layout (internal_server_error)

I have not changed the controller at all. Thank you everyone who is responding to this topic – it’s incredibly helpful to me. What can I do now to get past this hurdle?

——UPDATE #2——

Here is my application controller.

def current_user_session
  return @current_user_session if defined?(@current_user_session)
  @current_user_session = UserSession.find
end

def current_user
  return @current_user if defined?(@current_user)
  @current_user = current_user_session && current_user_session.user
end

def require_user
  unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to login_path
return false
  end
end

def require_no_user
  if current_user
store_location
flash[:notice] = "You must be logged out to access this page"
redirect_to root_url
return false
  end
end

Which one of these should be changed to @user_session?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:36:30+00:00Added an answer on May 14, 2026 at 11:36 pm

    A good idea is to use form_for if you possibly can:

    <% form_for @user_session do |f| %>
      <p>
        <%= f.label :username %>
        <%= f.text_field :username, :class => :inputBox %>
      </p>
      <p>
        <%= f.label :password %>
        <%= f.password_field :password, :class => :inputBox %>
      </p>
      <p><%= f.submit "submit", :class => :submit %></p>
    <% end %>
    

    Apart from that hard to say. Does your log file give any detail (aka errors)? Also try to add the errors on the table to you flash so that you can see what’s going wrong.

    Since it seems fro your last update that @user_session is not set, just go ahead and create one: <% form_for UserSession.new do |f| %>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 405k
  • Answers 405k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It would be useful to know what's actually in the… May 15, 2026 at 5:51 am
  • Editorial Team
    Editorial Team added an answer It is a macro definition for an exception class. It… May 15, 2026 at 5:51 am
  • Editorial Team
    Editorial Team added an answer You address this by using changeVersion. The API supports database… May 15, 2026 at 5:51 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.