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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:03:01+00:00 2026-05-31T03:03:01+00:00

In the standard index method of controller I set some value in the params

  • 0

In the standard “index” method of controller I set some value in the params hash in order to use it in the view if it’s not initialized yet in other case do nothing.

def index
  params[:my_value] ||= {}
end

when I use include? method on the params[:my_value] in the view, there’s an error evaluating nil.include?

Why there’s such error if params[:my_value] cannot be nil. If it’s nil, its value should be initialized with {}, that’s what ||= operator does. What can be the problem here?

  • 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-31T03:03:02+00:00Added an answer on May 31, 2026 at 3:03 am

    The solution was in the merge method. It turned out that

    a = b.merge(a) 
    

    and

    a.merge(b) {|key, v1, v2| v1 }
    

    do different things and in the first case(which was wrong) nil appears somewhere. I haven’t figured out yet why is it so because merge method always return a hash and when I replaced the first variant with the second everything was ok. So I don’t see any problem…

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

Sidebar

Related Questions

Take the standard return statement for a controller: return View(Index); is there a way
From the standard LogOn method in the account controller in MVC3 applications, how can
If we use this standard route: routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL
I'm having a weird problem with index organized table. I'm running Oracle 11g standard.
In standard ASP.net applications ASP.net offered some protection from XSS attacks with validateRequest throwing
Here is my setup, a bit changed standard edition. # app/config/routing.yml _internal: resource: @AcmeDemoBundle/Controller/
I have a form I need to use on multiple pages: Controller $emailForm =
I'm trying to add a QLPreviewController's view as a subview (no--I cannot use a
In the C++ standard libraries I found only a floating point log method. Now
Context: Imagine that you have a standard CherryPy hello word app: def index(self): return

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.