Controller inheritance problem

Hi,

problems with inheritance (:: issues?)
i have the following two controllers:

application.rb
pages_contoller.rb

(PagesController < applicationController::Base )

in the applicationcontroller, i have some methods that implement the acl
system in my app (i.e,

require “acl_system”
class ApplicationController < ActionController::Base
include ACLSystem
etc…

which is spread across all of my controllers
(inlcuding the PageController < ApplicationController)

lately i’ve created a third controller, cms_controller.rb, which i want
to inherit all methods/functions from the above two.

so i did:

Class CmsController < PagesController < ApplicationController
doesn’t work
Class CmsController < PagesController::ApplicationController
works only for methods in PagesController
Class CmsController < ApplicationController::PagesController
works only for methods in ApplicationController

— shouldn’t

Class CmsController < PagesController

be enough? if Pages < Application, shouldn’t Cms < Pages be enough to
inherit both controller methods?

i obviously am missing some important basic inheritance knowledge (at
least, i hope i am)…if someone could fill me in or point me out to
some reference, i would greatly appreciate it.

tia,

s

Conrad T. wrote:

Hi Tia, Ruby doesn’t support multiple inheritance but it supports what
is called a mixin module or simply a mixin. Please reference
“Programming Ruby” pages 118 - 120.

Good luck,

-Conrad

ok…

so i ‘require’ this module? it’s not a module, it’s a
ApplicationController / PagesController class, it’s not a module
Something. i’m supposed to do require ‘PagesController’ and it will call
all the methods from the pages-controller automaticly? …doesn’t seem
to work just like that. . . unfortunately, i feel a little lost…

Hi Tia, Ruby doesn’t support multiple inheritance but it supports what
is called a mixin module or simply a mixin. Please reference
“Programming Ruby” pages 118 - 120.

Good luck,

-Conrad

harper wrote:

ok…

so i ‘require’ this module? it’s not a module, it’s a
ApplicationController / PagesController class, it’s not a module
Something. i’m supposed to do require ‘PagesController’ and it will
call all the methods from the pages-controller automaticly? …doesn’t
seem to work just like that. . . unfortunately, i feel a little lost…

The point is, you’re trying to inherit from two parents, which Ruby
doesn’t support. The way around this – in Ruby – is, as Conrad said,
to use a module in which the methods you want are defined and then mix
this in.