# Different application.rb files for different scenarios?

**URL:** <https://www.ruby-forum.com/t/different-application-rb-files-for-different-scenarios/92803>\
**Category:** Rails\
**Created:** [April 24, 2007, 12:30pm UTC](https://www.ruby-forum.com/t/different-application-rb-files-for-different-scenarios/92803 "2007-04-24T12:30:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [April 24, 2007, 12:30pm UTC](https://www.ruby-forum.com/t/different-application-rb-files-for-different-scenarios/92803/1 "2007-04-24T12:30:11Z")

</div>

Hey 🙂

## I’ve created a CMS-like pages system, that renders dynamic content by picking up failed urls using a route,

# Catch all that wasn’t routed, and send it to the dynamic page

## content renderer: map.connect ‘\*absolute\_url’, :controller =\> ‘content’, :action =\> ‘page’

## In /app/controllers I now only have:

## /app/ controllers/ manage/ pages\_controller.rb …and many more… application.rb content\_controller.rb

The manage subfolder is for the backend. Everything frontend is  
generated by the content\_controller.

The application.rb provides filters, login functionality and more for  
ATM both the frontend and the backend. I’d like to separate this, so  
that I’d have for instance an application.rb file that works like it  
does now, then an application\_frontend.rb, and an  
application\_backend.rb.

## I thought I could add a module, ‘/lib/application\_backend.rb’ and then do,

## include ApplicationBackend if self.class.controller\_path.gsub(//.\* $/, ‘’) == ‘manage’

but then I get ‘undefined method `controller\_path’ for Class:Class’…

Is there any way to do what I want to do here? I’m not sure how to go  
about it.

Thanks in advance for any tips,

Daniel 🙂

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [April 24, 2007, 4:27pm UTC](https://www.ruby-forum.com/t/different-application-rb-files-for-different-scenarios/92803/2 "2007-04-24T16:27:17Z")

</div>

You don’t have to use application.rb, you can create any controller  
class you wish and inherit from that class. For example,

class PagesController \< ApplicationFrontendController  
…  
end

class MorePagesController \< ApplicationFrontendController  
…  
end

class OtherController \< ApplicationBackendController  
…  
end

class ApplicationFrontendController \< ApplicationController  
…  
end

class ApplicationBackendController \< ApplicationController  
…  
end
