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 5939305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:48:33+00:00 2026-05-22T15:48:33+00:00

My create user method in the users_controller.rb looks like: def process_login is_login_valid(params[:user][:user_name], params[:user][:password]) if

  • 0

My create user method in the users_controller.rb looks like:

def process_login
   is_login_valid(params[:user][:user_name], params[:user][:password])

   if logged_in?
      redirect_to root_url
   else
      @user = User.new(params[:user][:user_name]
      redirect_to :action => 'login'
end

What I have currently:

describe UsersController do
  describe "Post 'process_login'"
    it "should be successful" do
       post 'process_login'

       response.should be_success
    end
  end

end

The methods is_login_valid and logged_in? are all included in the application_controller, and are methods from a ruby class I have in my /lib folder called LoginSystem.rb

My test is failing since it isn’t mocking things correctly, this is my first time doing this so hoping someone can help me out.

Error message:

UsersController POST 'process_login' should be successful
     Failure/Error: post 'process_login'
     NoMethodError:
       You have a nil object when you didn't expect it!
       You might have expected an instance of ActiveRecord::Base.
       The error occurred while evaluating nil.[]
     # ./app/controllers/users_controller.rb:11:in `process_login'
     # ./spec/controllers/users_controller_spec.rb:21
  • 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-22T15:48:34+00:00Added an answer on May 22, 2026 at 3:48 pm

    Aah, Thanks for the error message. I’m assuming that line 11 is is_login_valid(params[:user][:user_name], params[:user][:password]).

    As you’re not sending any params in your test post params[:user] is nil hence the nil.[] error (when the controller is looking for params[:user][:user_name]), you set params by passing them as a hash as the 2nd parameter to post in your test.

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

Sidebar

Related Questions

I'd like to create a before_filter method in my application controller like this... def
I'm trying to create a user control that allows users to make something like
I am trying to create a winForms user control. But I want would like
Currently I authenticate the user using omniauth. This looks like this in my sessions
I create a new user with basic fields as user name and password. Then
Can anyone recommend a program to create user manuals with? Not a markup language
Trying to create a user account in a test. But getting a Object reference
I am trying to create a user interface using XAML. However, the file is
Is it possible to create a user with permissions of both a local administrator
Does anyone know of any software that can be used to create Agile User

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.