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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:43:07+00:00 2026-05-23T17:43:07+00:00

Possible Duplicate: Why doesn't this code produce the desired result? I have the code:

  • 0

Possible Duplicate:
Why doesn't this code produce the desired result?

I have the code:

def check_beta_code
    beta_code_array = ['AAAAAAAAAA', 'BBBBBBBBBB', 'CCCCCCCCCC', 'DDDDDDDDDD', 'EEEEEEEEEE']
    beta_code_array.each do |code|
        if :beta_code != code
            errors.add(:beta_code, "Invalid Beta Code")
        end
    end 
end

The problem with this code is that even if someone inputs a correct password, 4 errors are still generated because the other 4 aren’t correct.

  • 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-23T17:43:08+00:00Added an answer on May 23, 2026 at 5:43 pm

    I’m assuming this code is in a model somewhere. You can try creating a model that holds the beta codes and store some values in the DB. Then it’s just a matter of querying the db for the code and seeing if there’s a match:

    # model
    class BetaCode < ActiveRecord::Base
      # assumes a field named 'code'
    end
    
    # add some codes (via migration, console, manually, etc)
    ['AAAAAAAAAA', 'BBBBBBBBBB', 'CCCCCCCCCC', 'DDDDDDDDDD', 'EEEEEEEEEE'].each do |code|
      BetaCode.create(:code => code )
    end
    
    # and check for a match when user submits code (controller)
    @code = BetaCode.find_by_code(user_code)
    
    if @code.present?
      # user is approved
    else
      # sorry, no luck
    end
    

    If you want to use your snippet, you can always use the member? method for an array.

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

Sidebar

Related Questions

Possible Duplicate: NSTimer doesn't stop I have this code: [NSTimer scheduledTimerWithTimeInterval:110.0 target:self selector:@selector(targetMethod:) userInfo:nil
Possible Duplicate: problem with template inheritance This code doesn't compile in GCC: template <typename
Possible Duplicate: Javascript doesn't work in IE8 I have the following code var ind=1;
Possible Duplicate: C programming, why does this large array declaration produce a segmentation fault?
Possible Duplicate: Which keycode for escape key with jQuery This little piece of code
Possible Duplicate: Insert line into a query result (sum) I have a report that
Possible Duplicate: Form that removes WWW. and prints result on input? I'm using this
Possible Duplicate: Why doesn't the CLR always call value type constructors Found next code
Possible Duplicate: Why doesn't the weakref work on this bound method? I'm using weakrefs
Possible Duplicate: Why doesn't the weakref work on this bound method? A bit of

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.