[Rails] Re: Does anyone know how to access a module namespace using a chained method?
If I call Engine::BlogPost everything is gravy,
If I call BlogPost then I get...
uninitialized constant BlogPost
On Jun 8, 11:35 am, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> On Jun 7, 3:16 pm, frizbe1605 <frizbe1...@gmail.com> wrote:
>
> > Okay, I'm chaining methods. I want access to my class. I can access
> > SomeClass with a method like some_class. Now with engines in Rails
> > 3.1, I can use modules to break apart my codebase. So now, SomeClass
> > would beEngine::SomeClass. If I try to accessEngine::SomeClass with
> > a similar style method like engine_some_class, it returns with
> > EngineSomeClass rather thanEngine::SomeClass.
>
> I think you are expecting magic where there is none. If your blog
> model has belogns_to :blog_post, ... then you'll always do
> Blog.first.blog_post, whether blog_post is a BlogPost,
> Engine::BlogPost or some other class altogether
>
> Fred
>
>
>
>
>
>
>
>
>
> > Any ideas on a chainable method for accessing this class now that it
> > has the additional module namespace?
>
> > Thanks,
>
> > Steve
>
> > On Jun 6, 1:35 pm, Frederick Cheung <frederick.che...@gmail.com>
> > wrote:
>
> > > On Jun 6, 3:34 pm, frizbe1605 <frizbe1...@gmail.com> wrote:> EngineBlogPost == @blog.engine_blog_post
> > > >Engine::BlogPost == ????????
>
> > > You might want to elaborate - to me at least your question makes no
> > > sense.
>
> > > Fred.
>
> > > > Thanks!
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home