Are these two below the same thing? 1. module X module Y class Z 2. class X::Y::Z -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 14 April 2010 01:45, Me <chabgood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are these two below the same thing? > > 1. module X > module Y > class Z > > > 2. class X::Y::Z >Providing class Z has already been created with style 1, yes. If you try to run style 2 without X and Y having been created you will get "NameError: uninitialized constant X". The difference between class and module in Ruby is fairly minimal (and mainly used for inferring a difference in usage to the reader) Cheers, Andy -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
ok as far as controllers are concerned in a RoR app would either of those style matter as far as name spacing? On Wed, Apr 14, 2010 at 02:35, Andy Jeffries <andyjeffries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 14 April 2010 01:45, Me <chabgood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Are these two below the same thing? >> >> 1. module X >> module Y >> class Z >> >> >> 2. class X::Y::Z >> > > Providing class Z has already been created with style 1, yes. > > If you try to run style 2 without X and Y having been created you will get > "NameError: uninitialized constant X". > > The difference between class and module in Ruby is fairly minimal (and > mainly used for inferring a difference in usage to the reader) > > Cheers, > > > Andy > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 14 April 2010 15:18, Chris Habgood <chabgood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ok as far as controllers are concerned in a RoR app would either of those > style matter as far as name spacing? >Nope, won''t matter a jot. But if you have this: class Admin::FooController end without declaring Admin first you''ll get an error. What I tend to do is this: module Admin class BaseController def some_admin_method ... end end end Because you need to declare Admin before you can just randomly start using it. Then I do this when declaring a subclass: class PagesController < Admin::BaseController ... end Cheers, Andy -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
OK, that is what I thought, thanks. On Wed, Apr 14, 2010 at 09:33, Andy Jeffries <andyjeffries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 14 April 2010 15:18, Chris Habgood <chabgood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> ok as far as controllers are concerned in a RoR app would either of those >> style matter as far as name spacing? >> > > Nope, won''t matter a jot. > > But if you have this: > > class Admin::FooController > > end > > without declaring Admin first you''ll get an error. > > What I tend to do is this: > > module Admin > class BaseController > def some_admin_method > ... > end > end > end > > Because you need to declare Admin before you can just randomly start using > it. Then I do this when declaring a subclass: > > class PagesController < Admin::BaseController > ... > end > > Cheers, > > > Andy > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.