Hi everybody,
I created a class called Customer and created a sub class called
Transaction. The problem iam facing is i can’t extract the super class
methods and variables from sub class (i.e from Transaction class).
the error it shows is
Hi everybody,
I created a class called Customer and created a sub class called
Transaction. The problem iam facing is i can’t extract the super class
methods and variables from sub class (i.e from Transaction class).
the error it shows is
Since you get the error in line 1 of the Transaction.rb file, I guess it
starts with
class Transaction < Customer
and I guess you define the class Customer in a file Customer.rb. If I’m
correct, you first have to require the file with the Customer class, so
your file Transaction.rb has to start with
require “Customer”
class Transaction < Customer
Some further remarks:
You don’t need to name the file after the class. And you don’t have to
define each class in its own file. For example, you could define both of
your classes in a file called “app.rb”.
I think Filenames with mixed uppercase and lowercase letters aren’t
often used in Ruby land.
How can a transaction be a subclass of a customer?
Hi Mr.Pit
Thanks for the solid information that u posted, yes the require
“Customer” is the sentence which i missed out…
Thanks again for ur info,
bye
Pit C. wrote:
gopal pusuluri schrieb:
Hi everybody,
I created a class called Customer and created a sub class called
Transaction. The problem iam facing is i can’t extract the super class
methods and variables from sub class (i.e from Transaction class).
the error it shows is
Since you get the error in line 1 of the Transaction.rb file, I guess it
starts with
class Transaction < Customer
and I guess you define the class Customer in a file Customer.rb. If I’m
correct, you first have to require the file with the Customer class, so
your file Transaction.rb has to start with
require “Customer”
class Transaction < Customer
Some further remarks:
You don’t need to name the file after the class. And you don’t have to
define each class in its own file. For example, you could define both of
your classes in a file called “app.rb”.
I think Filenames with mixed uppercase and lowercase letters aren’t
often used in Ruby land.
How can a transaction be a subclass of a customer?
Regards,
Pit
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.