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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:15:14+00:00 2026-06-13T02:15:14+00:00

I don’t know what I’m doing wrong so please help me out. So as

  • 0

I don’t know what I’m doing wrong so please help me out.

So as the title says all works great in the browser. So I guess it’s the spec I’m not able to get right.

I’ve rewrote code in my helpers, controllers and spec several times to.

Here’s my spec for now:

describe "visit as admin" do
    before do
      sign_in admin
      visit organization_users_path # row 20 of users_controller_spec
    end
    it "should display right page" do
      page.should have_selector('title', text: "Users") 
    end
  end

When i run it i get:

1) Organization::UsersController visit as admin should display right page
     Failure/Error: visit organization_users_path
     NoMethodError:
       undefined method `users' for nil:NilClass
     # ./app/controllers/organization/users_controller.rb:5:in `index'
     # ./spec/controllers/organization/users_controller_spec.rb:20:in `block (3 levels) in <top (required)>'

And heres my controller and helper:

# helper
def current_organization
  @current_organization ||= current_user.organization
end

def admin_user
  unless current_user.admin?
    redirect_to root_path
  end
end

#controller
class Organization::UsersController < ApplicationController
  before_filter :admin_user

  def index
    @users = current_organization.users
  end
end

Edit 1: From rake routes:

organization_users GET    /organization/users(.:format)          organization/users#index
  • 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-06-13T02:15:15+00:00Added an answer on June 13, 2026 at 2:15 am

    Seems like in the index function for the controller: current_organization is nil.

    Please make sure this helper is returning a valid object:

    def current_organization
      @current_organization ||= current_user.organization
      raise @current_organization.inspect # <--- use this to inspect this value and delete afterwards
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
Don't know what's wrong here, when I run the application it says Specified method
Don't know if it's I'm doing it wrong or if there's a bug (I
don't know if the title describes anything about what I'm trying to say but
Don't really know how to formulate the title, but it should be pretty obvious
Don't know if anyone can help me with this or if it's even possible.
I don't know: if this works. if it's a good idea. what it is
Don't get me wrong PDO is great but what I don't like about it,
don't understand: in my controller: @json = User.all.to_gmaps4rails do |user| \Title\: \#{user.email}\ end in
don't know better title for this, but here's my code. I have class 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.