I'm a bit confused with namespacing in engines. In a Rails engine, where isolate_namespace
is used,
module Blog
class Engine < Rails::Engine
isolate_namespace Blorgh
end
end
when is it required that you refer to objects with the namespace Blog
(e.g. Blog::Post
vs just Post
)?
As for example, within the controller of a Post
resource of the engine, is it ok to just do Post.find
? When it is absolutely required that you use Blog::Post
?
Also in models associations, assume that Post has_many :comments
. Somehow, I was expecting to define it as follows:
class Post < ActiveRecord::Base
:has_many "blog/comments"
end
since everything is namespaced (models, table names, ...), but it looks like has_many :comments
just works. Why namespacing is not used in association keys, and in the case where a Comment
resource exists in the host applications, how does rails know which Comment
I'm referring to?