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
--
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
-~----------~----~----~----~------~----~------~--~---
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 On 12/28/06, harper <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Conrad Taylor 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, > > -Conradok... 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... -- 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 -~----------~----~----~----~------~----~------~--~---
harper wrote:> > Conrad Taylor 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... >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. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---