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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:32:50+00:00 2026-05-26T10:32:50+00:00

Here is the code #add email of team lead of the current user def

  • 0

Here is the code

  #add email of team lead of the current user
  def add_the_tl_email(to_address, session_user_id)
    ul = UserLevel.find_by_user_id(session_user_id)
    if !ul.team.nil? && !ul.role.nil?
      User.user_status('active').joins(:user_levels).where(:user_levels => {:position => 'tl', 
                                                      :role => ul.role, 
                                                      :team => ul.team }).each do
        |u| to_address << u.email 
      end
    end
  end

The error from spec:

  1) CustomersController GET customer page 'create' successful should create one customer record
     Failure/Error: post 'create', :customer => @customer
     NoMethodError:
       undefined method `team' for nil:NilClass
     # ./app/mailers/user_mailer.rb:36:in `add_the_tl_email'
     # ./app/mailers/user_mailer.rb:15:in `notify_tl_dh_ch_ceo'
     # ./app/controllers/customers_controller.rb:27:in `create'
     # ./spec/controllers/customers_controller_spec.rb:48:in `block (5 levels) in <top (required)>'
     # ./spec/controllers/customers_controller_spec.rb:47:in `block (4 levels) in <top (required)>'

team is a field in user_level. Here is the user_level in factory:

Factory.define :user_level do |level|

  level.role                 "sales"
  level.position             "member"
  level.team                 1
  level.association          :user
end

In rails console, the ul.team.nil? returns either true or false on test data generated by factory.

Since team is a field in user_level, why there is error in spec like: NoMethodError:
undefined method `team’ for nil:NilClass ?

Thanks.

  • 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-26T10:32:50+00:00Added an answer on May 26, 2026 at 10:32 am

    The call in

     ul = UserLevel.find_by_user_id(session_user_id)
    

    returned nil and thus nil was assigned to ul.

    So when you called

    !ul.team.nil?
    

    Ruby tried to call team on nil. nil is an instance of NilClass and there is no method named team on NilClass.

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

Sidebar

Related Questions

I'm trying to add text to textarea in current pointer position, here's the code
Here's my code: $form = $this->createFormBuilder($signupAttempt) ->add('email', 'text', array(label => your email:)) ->add('password', 'password',
here my simple code to add filename and their associated icon to virtualtreeview PFileInfoRec
here is the code. void sendMail() { MailMessage mail = new MailMessage(); mail.To.Add(abc@gmail.com); mail.From
I download the latest source code from here: http://aspnetwebstack.codeplex.com/SourceControl/list/changesets 1) add the system.web.mvc project
How can i reset a display:none and add some value here is the code
Here's the line from App.Config: <add key=CheckFileFormatString value=P{0}\t&quot;{1}, {2}&quot;\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}/> Here's the code that puts
I'm trying to add controller to my Todo list app. Here's the code. $(function(){
I just wonder how to add annotation in matlab plot? Here is my code:
Here is an old add in to quickly comment out HTML code. Maybe I

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.