zend 模块就像在 Rails 中一样

发布于 2024-10-21 04:27:47 字数 392 浏览 0 评论 0原文

有没有办法像 zend 框架模块一样在 Rails 3 中创建模块?在 zend 框架中,您有一个类似于以下结构的文件夹“模块”:

/application/modules/admin
/application/modules/site
/application/modules/service 

并且它以这种方式路由:

http://myapp.local/admin
http://myapp.local/service
http://myapp.local/ -- to site module (default).

如何在 Rails 3 中实现此目的?有更好的方法在 Rails 中完成此类操作吗?

提前致谢

is there a way to do modules in rails 3 like zend framework modules ? In zend framework, you have a folder 'modules' like following structure:

/application/modules/admin
/application/modules/site
/application/modules/service 

and it's routed in this way:

http://myapp.local/admin
http://myapp.local/service
http://myapp.local/ -- to site module (default).

How can I achieve this in Rails 3? There's a better way to do this type things in rails ?

Thanks in advANCE

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰葑 2024-10-28 04:27:47

控制器命名空间怎么样?

                          # URL:
resources :projects       # /projects
resources :people         # /people

namespace "admin" do      # /admin
  resources :projects     # /admin/projects
  resources :people       # /admin/people
end

namespace "service" do    # /service
  resources :what         # /service/what
  resources :ever         # /service/ever
end

控制器路径:

app/controllers/projects_controller.rb
app/controllers/people_controller.rb
app/controllers/admin/projects_controller.rb
app/controllers/admin/people_controller.rb
app/controllers/service/what_controller.rb
app/controllers/service/ever_controller.rb

更多信息请参见:

http://guides.rubyonrails.org/ routing.html#controller-namespaces-and-routing

How about controller namespaces?

                          # URL:
resources :projects       # /projects
resources :people         # /people

namespace "admin" do      # /admin
  resources :projects     # /admin/projects
  resources :people       # /admin/people
end

namespace "service" do    # /service
  resources :what         # /service/what
  resources :ever         # /service/ever
end

Controller paths:

app/controllers/projects_controller.rb
app/controllers/people_controller.rb
app/controllers/admin/projects_controller.rb
app/controllers/admin/people_controller.rb
app/controllers/service/what_controller.rb
app/controllers/service/ever_controller.rb

More information here:

http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing

_失温 2024-10-28 04:27:47

这听起来有点像 Rails 3 的模型和路由。我不会说您需要一个特定的管理模型,这将是用户模型的扩展。

rails 路由指南 可能会正确地解释其中的一些内容。

This is sounding a little like Models and Routes for Rails 3. I wouldn't say you need a specific model for Admin, that would be an extension of the User model.

The rails routing guide might put some of this in perspective.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文