padrino:同名的子应用程序和控制器会产生冗余 url
我有一个 padrino 项目。
我创建了一个名为“用户”的子应用程序。
我还有一个名为 user 的模型和一个名为 users 的控制器来处理路由。
Users.controllers :users do
问题是生成和响应的网址是
app.com/users/users/index 等等,
除非我去每个动作并映射它
get :index, :map => '/' do
有更好的方法吗?
我真的不想将操作放在应用程序的 app.rb 中..即使效果很好。我喜欢分离。
有没有类似的
Users.controllers :users do
map '/'
end
命名约定,我可以遵循它来创建一个响应我的应用程序根 URL 的默认控制器?
我想将其保留在用户控制器中,以便我可以使用
捆绑包中包含的 users_index 等 Gems:
activemodel (3.2.1)
activerecord (3.2.1)
activesupport (3.2.1)
arel (3.0.0)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.0.21)
haml (3.1.4)
http_router (0.10.2)
i18n (0.6.0)
mail (2.3.0)
mime-types (1.17.2)
multi_json (1.0.4)
padrino (0.10.6.c)
padrino-admin (0.10.6.c)
padrino-cache (0.10.6.c)
padrino-core (0.10.6.c)
padrino-gen (0.10.6.c)
padrino-helpers (0.10.6.c)
padrino-mailer (0.10.6.c)
polyglot (0.3.3)
rack (1.4.1)
rack-protection (1.2.0)
rack-test (0.6.1)
rake (0.9.2.2)
sass (3.1.13)
shoulda (2.11.3)
sinatra (1.3.2)
sinatra-flash (0.3.0)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)
url_mount (0.2.1)
如果当我的应用程序名称与我的控制器名称匹配时我必须映射控制器中每个操作的路径,那很好。我只是想知道是否有一种方法可以通过控制器为我的所有操作设置基本路径或根路径。
谢谢
I have a padrino project.
I've created a sub app called "users".
I also have a model called user and a controller called users to handle the routing.
Users.controllers :users do
The issue with that is that the urls being produced and being responded to are
app.com/users/users/index
etc
unless I go to each action and map it
get :index, :map => '/' do
Is there a better way of doing this?
I don't really want to put the actions in the app.rb for the app.. even though that works great. I like having the separation.
Is there anything like
Users.controllers :users do
map '/'
end
Is there a naming convention that I can follow to create a default controller that would response to my apps root url?
I'd like to keep it in the users controller so that I can use the users_index etc
Gems included by the bundle:
activemodel (3.2.1)
activerecord (3.2.1)
activesupport (3.2.1)
arel (3.0.0)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.0.21)
haml (3.1.4)
http_router (0.10.2)
i18n (0.6.0)
mail (2.3.0)
mime-types (1.17.2)
multi_json (1.0.4)
padrino (0.10.6.c)
padrino-admin (0.10.6.c)
padrino-cache (0.10.6.c)
padrino-core (0.10.6.c)
padrino-gen (0.10.6.c)
padrino-helpers (0.10.6.c)
padrino-mailer (0.10.6.c)
polyglot (0.3.3)
rack (1.4.1)
rack-protection (1.2.0)
rack-test (0.6.1)
rake (0.9.2.2)
sass (3.1.13)
shoulda (2.11.3)
sinatra (1.3.2)
sinatra-flash (0.3.0)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)
url_mount (0.2.1)
If I have to map the path for each action in the controller when my app name matches my controller name, that's fine. I was just wondering if there was a way to set the base or root path for all my actions via the controller.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,现在如果我有一个名为 Users 的应用程序和一个名为 Users 的控制器来处理路由,我可以只说 /users 或 /users/new 等,而不是 /users/users/new 。
再说一遍,我对此很陌生,所以我不知道这是否是处理此问题的最佳方法。我可以在每条路线中手动设置地图,但这会很烦人。
我希望 DAddYE 能够重视这一点并提供更好的建议。
So now if I have an application called Users and a controller called Users to handle the routes, I can just say /users or /users/new etc instead of /users/users/new.
Again, I'm very new to this, so I have no idea if this is the best way to handle this. I could have just set the map manually in each route, but that would be very annoying.
I'm hoping that DAddYE can weight in on this and provide a better recommendation.
您可以直接使用:
You can use directly: