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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:03:58+00:00 2026-06-06T14:03:58+00:00

In my controller i am merging the results of two different instance variables into

  • 0

In my controller i am merging the results of two different instance variables into one instance variable and i got an following error:

undefined method `<<' for nil:NilClass

Here is my controller code

  @conversational = InterestType.where("institution_id = ? or global = ? and category_id = ?", current_user.profile.institution_id, true, 1).first

    @commercial = InterestType.where("institution_id = ? or global = ? and category_id = ?", current_user.profile.institution_id, true, 2).limit(17)

    @user_interest_types << @conversational

    @user_interest_types << @commercial

How can i get over of this error or what is the good way to get following result.

  1. I want to display first conversational interest type then other 17 commercial interest types.
  • 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-06T14:04:00+00:00Added an answer on June 6, 2026 at 2:04 pm

    If you want to append to an array you have two options and here you must pay attention to what you’re adding:

    # Define an empty array
    @user_interest_types = [ ]
    
    # Add a single element to an array
    @user_interest_types << @conversational
    
    # Append an array to an array
    @user_interest_types += @commercial
    

    If you use << for both operations you end up pushing an array into an array and the resulting structure has multiple layers. You can see this if you call inspect on the result.

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

Sidebar

Related Questions

I have two rails apps that I am thinking about merging into one because
I can't seem to find a method to call different controller in the same
I'm having trouble merging the two concepts of using a SplitViewController in my main
AFAIK, there are two ways of passing data to the view from controller :
Controller ClientDocument. def upload_document ClientDocument.upload_client_document(params) end Model ClientDocument. Class method.. def self.upload_client_document(params) self.new :uploaded_data
Controller Call user = User.authenticate(params[:session][:email], params[:session][:password]) Authenticate Method in user.rb class << self def
Controller function login() { // Don't show the error message if no data has
controller: @Controller @SessionAttributes public class ContactController { @RequestMapping(value = /addContact, method = RequestMethod.POST) public
My controller method just return String value. When I called JSON from my view
Background I've got the following tree of objects: Name Project Users nil John nil

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.