I am trying to understand how I can use a return from a method as a
constant name for a class. What I am trying to do is take a return I
find in a db table and use that name as a class name so that I can use
activerecord. I admit my understanding of ActiveRecord is extremely
immature so perhaps I am using it wrong.
…
perMatrtix = subMatrix.find[:space].to.upcase
class perMatrix < ActiveRecord::Base; end
blah, blah, blah…
So the return of the find, which is a name (turn to upper) as the name
of a class so that I can access that table within the database.
So the return of the find, which is a name (turn to upper) as the name of a class so that I can access that table within the database.
If you’re getting the class name at run-time how would you write code
that uses class after you’ve created it? I mean, you can’t type the
class name into your program now, you don’t know what it is?
I suspect that what you really want to do is simply create a class and
assign the result to a variable. Check out Class.new.
Thank you much for the example. This truly helps. WRT you question,
its a typo and basically its a method that retrieves the various
submatrix of a giant sparse matrix. I am using a db to organize all the
data so that I can run the calculations simultaneously across several
hundred machines. The orchestration of data and control flow of
processing I am trying to do in ruby.
Again, thanks for help!
Cheers,
Phy
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.