# Moving an existing app to an extension

**URL:** <https://www.ruby-forum.com/t/moving-an-existing-app-to-an-extension/148998>\
**Category:** Radiant CMS\
**Created:** [September 19, 2008, 4:34am UTC](https://www.ruby-forum.com/t/moving-an-existing-app-to-an-extension/148998 "2008-09-19T04:34:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewkendall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@andrewkendall](https://www.ruby-forum.com/u/andrewkendall)\
**Post date:** [September 19, 2008, 4:34am UTC](https://www.ruby-forum.com/t/moving-an-existing-app-to-an-extension/148998/1 "2008-09-19T04:34:19Z")

</div>

Hello,

I have an existing application that I’m converting to a Radiant  
extension and I was wondering what the best thing to do is with respect  
to code I have in my existing applications ApplicationController and  
ApplicationHelper? I can’t redefine the ApplicationController, but I’d  
like to take some of the code I have in it and “extend” Radiant’s  
ApplicationController with my own custom code since all of my  
application controllers already derive from ApplicationController.

Any recommendations on the approach to take?

Thanks,  
Andrew

---

<div class="post-metadata">

**Author:** ![andrewkendall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@andrewkendall](https://www.ruby-forum.com/u/andrewkendall)\
**Post date:** [September 19, 2008, 4:42am UTC](https://www.ruby-forum.com/t/moving-an-existing-app-to-an-extension/148998/2 "2008-09-19T04:42:40Z")

</div>

Andrew K. wrote:

> Hello,
> 
> I have an existing application that I’m converting to a Radiant  
> extension and I was wondering what the best thing to do is with respect  
> to code I have in my existing applications ApplicationController and  
> ApplicationHelper? I can’t redefine the ApplicationController, but I’d  
> like to take some of the code I have in it and “extend” Radiant’s  
> ApplicationController with my own custom code since all of my  
> application controllers already derive from ApplicationController.
> 
> Any recommendations on the approach to take?
> 
> Thanks,  
> Andrew

I’m thinking that perhaps creating a new base class for a controller is  
the cleanest approach.

So  
class MyNewBaseController \< ApplicationController  
end

And all my existing controller derive from MyNewBaseController.

It means I have to update all of my controllers now, but is this how I  
should do it?

---

<div class="post-metadata">

**Author:** ![andrewkendall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@andrewkendall](https://www.ruby-forum.com/u/andrewkendall)\
**Post date:** [September 19, 2008, 4:43am UTC](https://www.ruby-forum.com/t/moving-an-existing-app-to-an-extension/148998/3 "2008-09-19T04:43:43Z")

</div>

Create a controller in your extension and have it inherit from  
ApplicationController. Put all of the code that you want to keep from  
ApplicationController and put it in there. Then, change all of your  
controllers to inherit from this controller, rather than from  
ApplicationController.

This will let all of your controllers inherit these methods you want  
to share, without polluting Radiant’s ApplicationController class.

Jamey

---

<div class="post-metadata">

**Author:** ![andrewkendall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@andrewkendall](https://www.ruby-forum.com/u/andrewkendall)\
**Post date:** [September 19, 2008, 4:44am UTC](https://www.ruby-forum.com/t/moving-an-existing-app-to-an-extension/148998/4 "2008-09-19T04:44:41Z")

</div>

Jamey C. wrote:

> Create a controller in your extension and have it inherit from  
> ApplicationController. Put all of the code that you want to keep from  
> ApplicationController and put it in there. Then, change all of your  
> controllers to inherit from this controller, rather than from  
> ApplicationController.
> 
> This will let all of your controllers inherit these methods you want  
> to share, without polluting Radiant’s ApplicationController class.
> 
> Jamey

Looks like I beat ya to my own solution… thanks for reaffirming what I  
was thinking!
