8000 Use isolated engines to simplify namespacing · Issue #8 · k3integrations/k3cms · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use isolated engines to simplify namespacing #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TylerRick opened this issue May 11, 2011 · 1 comment
Open

Use isolated engines to simplify namespacing #8

TylerRick opened this issue May 11, 2011 · 1 comment

Comments

@TylerRick
Copy link

Read the "Isolated Engine" section on http://edgeapi.rubyonrails.org/classes/Rails/Engine.html

The next thing that changes in isolated engines is the behaviour of routes. Normally, when you namespace your controllers, you also need to do namespace all your routes. With an isolated engine, the namespace is applied by default, so you can ignore it in routes:
MyEngine::Engine.routes.draw do
  resources :articles
end

The routes above will automatically point to MyEngine::ApplicationContoller. Furthermore, you don’t need to use longer url helpers like my_engine_articles_path. Instead, you should simply use articles_path as you would do with your application.

To make that behaviour consistent with other parts of the framework, an isolated engine also has influence on ActiveModel::Naming. When you use a namespaced model, like MyEngine::Article, it will normally use the prefix “my_engine”. In an isolated engine, the prefix will be omitted in url helpers and form fields for convenience.

polymorphic_url(MyEngine::Article.new) # => "articles_path"
@TylerRick
Copy link
Author

Hopefully will be available by 3.1 (not mentioned on http://api.rubyonrails.org/classes/Rails/Engine.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0