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

  • Home
  • SEARCH
  • 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 6224423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:40:14+00:00 2026-05-24T08:40:14+00:00

I want to perform the multiple tests within one URL, over may different URL’s.

  • 0

I want to perform the multiple tests within one URL, over may different URL’s.

I have code that works and writes to my mysql database but it only writes exactly what I put into the double quotes. If I wanted to define "x" or "mywebsite" as a variable and then have active record write the current value of the variable into the database how could I do this?

My code is currently:

require 'rubygems'
require 'active_record'
for x in a.each do
    if browser.text.include?(x.chomp)
        class Rubyist < ActiveRecord::Base
        Rubyist.create(:name => "x", :city => "mywebsite")
    end
end

Where “a” is an array of variables. And “mywebsite” is changed at the start of each test. the tests runs through and repeats for each value of x in the array.

If I put:

        Rubyist.create(:name => x, :city => mywebsite)

Then I get an error along the lines of:

some/long.path/to/active_record/base.rb:1014:in 'method_missing': undefined local variable or method 'x' for Rubyist(id: integer, name: string, city: text):Class (NameError)
  • 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-24T08:40:15+00:00Added an answer on May 24, 2026 at 8:40 am

    I still think for x in a.each do is redundant, but it does seem to work…

    Let me try answering your question again. The problem seems to be that you don’t close the definition of your class.

    This means the following is inside the class definition, where x is not defined:

    Rubyist.create(:name => x, :city => mywebsite)
    

    To fix this you have to close the class definition, before calling Rubyist.create:

    if browser.text.include?(x.chomp)
      class Rubyist < ActiveRecord::Base; end
      Rubyist.create(:name => x, :city => mywebsite)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that every time I want to perform a db query, I have
I have a client-side interface that allows the user to perform multiple edits against
I have 2 submit buttons and want to perform different actions for each submit
I want to make a curl call with a URL that has multiple parameters.
I have an input field (text) that I want to perform autocomplete on with
Whenever I execute a linux command that outputs multiple lines, I want to perform
I want to perform simple validation against multiple fields. Please note these fields are
I want to perform a printf() to display when the currently executing code was
I have a table on which I want to perform some operations every hour.
I have an INPUT element of the TEXT type and I want to perform

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.