Daniel Smedegaard Buus
2007-Apr-24 10:29 UTC
Different application.rb files for different scenarios?
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 :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wai Tsang
2007-Apr-24 14:27 UTC
Re: Different application.rb files for different scenarios?
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---