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

  • Home
  • SEARCH
  • 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 794421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:18:37+00:00 2026-05-14T22:18:37+00:00

So I’m working with authlogic, and I’m trying to duplicate the login functionality to

  • 0

So I’m working with authlogic, and I’m trying to duplicate the login functionality to the welcome page, so that you can log in by restful url or by just going to the main page. No, I don’t know if we’ll keep that feature, but I want to test it out anyway. Here’s the error message:

RuntimeError in Welcome#index
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

The code is below. Basically, what’s happening is the index view (the first code snippet) is sending the information from the form to the create method of user_sessions controller. At this point, in theory, it create should just pick up, but it doesn’t.

PLEASE help. Please. I’ve been doing this for about 8 hours. I checked Google. I checked IRC. I checked every book I could find. You don’t even have to answer, I can to the grunt work if you just point me in the right direction.

===EDIT EDIT EDIT===

Sameera was good enough to provide the answer to the problem. Open question, though is what the best way to organize the app is. Is applying the object @user_sessions in a before_filter acceptable, or is there a more rails-y way of doing this?

WELCOME#INDEX

<% form_for @user_session, :url => user_sessions_path do |f| %>
    <%= f.text_field :email %><br />
<%= f.password_field :password %>
<%= submit_tag 'Login' %>
<% end %>

APPLICATION CONTROLLER

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password
    helper_method :current_user_session, :current_user
    before_filter :new_session_object
protected
    def new_session_object
        unless current_user
        @user_session = UserSession.new(params[:user_session])
    end
end
private
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.record
end
end<pre></code>

USER SESSIONS CONTROLLER

class UserSessionsController < ApplicationController
  def new
    @user_session = UserSession.new
  end

  def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      flash[:notice] = "Logged in"
      redirect_to root_url
    else
      render :controller => 'user_sessions', :action => 'new'
    end
  end

  def destroy
    @user_session = UserSession.find
    @user_session.destroy
    flash[:notice] = "Logged out"
    redirect_to root_url
  end
end

A more detailed STACK TRACE

1: <h1>Welcome#index</h1>
2: <p>Find me in app/views/welcome/index.html.erb</p>
3: 
4: <% form_for @user_session, :url => user_sessions_path do |f| %>
5:  <%= f.text_field :email %><br />
6:      <%= f.password_field :password %>
7:  <%= submit_tag 'Login' %>

Application Trace | Framework Trace | Full Trace
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpac -2.3.5/lib/action_controller/record_identifier.rb:76:in `dom_id'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/record_identification_helper.rb:16:in `dom_id'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:293:in `apply_form_for_options!'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:277:in `form_for'
/Users/alex/Desktop/anglic/app/views/welcome/index.html.erb:4:in `_run_erb_app47views47welcome47index46html46erb'
  • 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-14T22:18:38+00:00Added an answer on May 14, 2026 at 10:18 pm

    Try this:

    form_for :user_session, @user_session, :url => user_session_path(@user_session)} do |f| 
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here you can find the code that I use in… May 14, 2026 at 11:47 pm
  • Editorial Team
    Editorial Team added an answer since neither answer gave you the full solution : @OneToMany… May 14, 2026 at 11:47 pm
  • Editorial Team
    Editorial Team added an answer I have some code in a Cat App that uses… May 14, 2026 at 11:47 pm

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.