# Subclass does not call super in constructor

**URL:** <https://www.ruby-forum.com/t/subclass-does-not-call-super-in-constructor/144226>\
**Category:** Rails\
**Created:** [July 27, 2008, 1:09am UTC](https://www.ruby-forum.com/t/subclass-does-not-call-super-in-constructor/144226 "2008-07-27T01:09:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [July 27, 2008, 1:09am UTC](https://www.ruby-forum.com/t/subclass-does-not-call-super-in-constructor/144226/1 "2008-07-27T01:09:58Z")

</div>

I am working with the book agile Web D. second edition, and in  
page 110 there is an example i how to create the model CartItem.

I am using rails 2.0 and after adding the class CartItem I get an error  
at the constructor Initialize

class CartItem \< ActiveRecord::Base  
attr\_reader :product, :quantity

def initialize(product)  
@product = product  
@quantity = 1  
end

it underlines the word “initialize” and says “Subclass does not call  
super in constructor”

---

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [July 28, 2008, 1:33am UTC](https://www.ruby-forum.com/t/subclass-does-not-call-super-in-constructor/144226/2 "2008-07-28T01:33:33Z")

</div>

On Sun, Jul 27, 2008 at 12:09 AM, Pepe S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am working with the book agile Web D. second edition, and in  
> page 110 there is an example i how to create the model CartItem.
> 
> I am using rails 2.0 and after adding the class CartItem I get an error  
> at the constructor Initialize
> 
> class CartItem \< ActiveRecord::Base

Check the example again - CartItem doesn’t inherit from ActiveRecord.

Barry
