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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:12:37+00:00 2026-05-23T13:12:37+00:00

The error: You have a nil object when you didn’t expect it! You might

  • 0

The error:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]


app/controllers/users_controller.rb:45:in `update'

Controller users_controller

def update
    @user.groups = Group.find(@params[:group_ids]) if @params[:group_ids]
    if @user.update_attributes(params[:user])
      flash[:success] = "User updated."
      #Redirect back to current users, i've change this as after the admin edit a user it would redirect them
      #Too that users account which conflicts.
      #if current_user.admin? # If the current user is an admin move them back to the user list page.
        #redirect_to users_path
      #else # if its a normal user just redirect them back to there dashboard
        redirect_to @user
      #end
    else
      @title = "Edit user"
      render 'edit'
    end
  end

The view (edit.html.erb):

<% for group in @groups %>
    <%= check_box_tag "user[group_ids][]", group.id %>
    <%= group.description %>
    <% end %>
  • 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-23T13:12:38+00:00Added an answer on May 23, 2026 at 1:12 pm
    @user.groups = Group.find(@params[:group_ids]) if @params[:group_ids]
    
    @user.groups = Group.find(params[:group_ids]) if params[:group_ids]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting the error: You have a nil object when you didn't expect it! You
I'm getting this error with the Paperclip gem. NoMethodError (You have a nil object
I have the following check for nil: client = !deal['deal']['party']['party'].nil? ? deal['deal']['party']['party']['company_id'] : but
I'm getting the following error in my Rails application and I have no idea
I am having a weird error when using Omniauth. This appears to have little
I have the following code in my application helper. route = ActionController::Routing::Routes.recognize_path(current_uri) controller =
I'm trying to figure out how to add records to an existing object for
This is the code: xml = REXML::Document.new(data) @contacts = Array.new xml.elements.each('//entry') do |entry| person
I have a Rails application that lately is behaving very weird. If I start
Been Facing this issue,I Have as my view <%= form_for(:pin, :url => {:action =>fees})

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.