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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:41:49+00:00 2026-05-23T01:41:49+00:00

I am verifying the existence of test_results in the application controller. It is returned

  • 0

I am verifying the existence of “test_results” in the application controller. It is returned as a local variable. I would like to call it once and have it available for the whole session. How do i do that?

“test_results” in application controller:

  def test_results
    (0 .. 4).each do |x| # looks for answers to the first 4 questions
      if @answers[x].nil? || @answers[x] == 0.0
        return false
        break
      end
    end
    return true
  end

other controllers:

before_filter :test_results

if test_results
   ...do stuff
else
   ...display "take the test"
end

error message from view:

undefined local variable or method `test_results'
  • 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-23T01:41:50+00:00Added an answer on May 23, 2026 at 1:41 am

    You can try using @

     if @instrument_results
    

    Edit

    The result of before filter isn’t stored. I don’t know what you want to do but you can set a controller level variable inside the test_results function and then referer it as @controller.variable_name. But if your intention is to make a conditional view based on test_results return value, I suggest you to make a redirect to another action in the test_results method and put the success content in the current controller.
    You can use :only and :except modifier to check which action of the controller will call the :before_filter.
    Hope this helps.

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

Sidebar

Related Questions

I'd like a simple way of verifying that ES is available to a Java
I'd like to use XMLDSIG for verifying that a .config file has not been
There have been other questions regarding the subject of verifying the accessibility and accessibility
I have a problem verifying a SOAP message timestamp and body. Before starting to
What would be the proper way of verifying if a user is currently logged
I'm actually creating a web application using PHP and seek help verifying a user.
i have the problem of retrieving the querystring and verifying the email in mvc3
I am developing a C# Application and I was verifying the setting for publishing
I have created a function that restricts route access by verifying that a stored
Our (ASP.Net) application has to talk to an LDAP/Active Directory server for verifying 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.