# Instantiating a Derived Class from an Instance of Base Class

**URL:** <https://www.ruby-forum.com/t/instantiating-a-derived-class-from-an-instance-of-base-class/70626>\
**Category:** Rails\
**Created:** [October 1, 2006, 2:31am UTC](https://www.ruby-forum.com/t/instantiating-a-derived-class-from-an-instance-of-base-class/70626 "2006-10-01T02:31:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 1, 2006, 2:31am UTC](https://www.ruby-forum.com/t/instantiating-a-derived-class-from-an-instance-of-base-class/70626/1 "2006-10-01T02:31:22Z")

</div>

I’ve got a ‘Task’ base class and a ‘ScheduledTask’ derived class that  
I’m currently using with single table inheritance.

I’m trying to create a new ScheduledTask instance from an existing Task  
instance:

scheduled\_task = ScheduledTask.new(task)

but I get a NoMethodError: undefined method `stringify\_keys!’ for  
#Task:0x395d2a8.

I can get around this if I just instantiate a “blank” ScheduledTask  
(.new) and manually fill in all of the shared attributes, but I know  
there’s gotta be an easier way. Please advise.

Thanks!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 2, 2006, 4:29pm UTC](https://www.ruby-forum.com/t/instantiating-a-derived-class-from-an-instance-of-base-class/70626/2 "2006-10-02T16:29:06Z")

</div>

bump
