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)
I still think
for x in a.each dois 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
xis not defined:To fix this you have to close the class definition, before calling
Rubyist.create: