好啊。这太疯狂了。
我对ror还不熟悉,我真的很想了解它,因为到目前为止我所看到的一切都使它对我所做的工作更具吸引力。
然而,我似乎无法完成
非常
关于罗的简单事情。
我要这些控制器:
/admin/blog/entries (index/show/edit/delete)
/admin/blog/categories (index/show/edit/delete)
/admin/blog/comments (index/show/edit/delete)
... and so on
这些模型:
Blog::Entry (table: blog_entries)
Blog::Category (table: blog_categories)
Blog::Comments (table: blog_comments)
... and so on
现在,我已经经历了相当多的痛苦,使这项工作。我的第一次尝试是生成脚手架(我使用2.2.2)。我生成了我的脚手架,但是必须移动我的模型,然后在我的控制器中修复对模型的引用(参见
Ruby on Rails model inside namespace can't be found in controller
)
这已经是一个很大的痛苦,但嘿,我有它的工作。现在,虽然form_for不起作用,我也不知道如何使用url帮助程序(我不知道这些被称为…它们是自动生成的方法,将url返回给与模型关联的控制器。我不知道他们叫什么名字。我的模型是blog::entries。我试着搞乱路线。rb地图的资源方法,但是没有运气。当我试图将form_用于我的模型时,我得到了这个错误
undefined method `blog_entries_path' for #<ActionView::Base:0xb6848080>
现在。这真的很令人沮丧。为了使用这个框架,我不会完全破坏代码的组织,如果我不知道如何完成这个简单的任务(我已经研究了至少5个小时),那么我就不能继续了。
有什么办法可以做到这一点吗?
谢谢
编辑
以下是我的路线:
admin_blog_entries GET /admin_blog_entries {:controller=>"admin_blog_entries", :action=>"index"}
formatted_admin_blog_entries GET /admin_blog_entries.:format {:controller=>"admin_blog_entries", :action=>"index"}
POST /admin_blog_entries {:controller=>"admin_blog_entries", :action=>"create"}
POST /admin_blog_entries.:format {:controller=>"admin_blog_entries", :action=>"create"}
new_admin_blog_entry GET /admin_blog_entries/new {:controller=>"admin_blog_entries", :action=>"new"}
formatted_new_admin_blog_entry GET /admin_blog_entries/new.:format {:controller=>"admin_blog_entries", :action=>"new"}
edit_admin_blog_entry GET /admin_blog_entries/:id/edit {:controller=>"admin_blog_entries", :action=>"edit"}
formatted_edit_admin_blog_entry GET /admin_blog_entries/:id/edit.:format {:controller=>"admin_blog_entries", :action=>"edit"}
admin_blog_entry GET /admin_blog_entries/:id {:controller=>"admin_blog_entries", :action=>"show"}
formatted_admin_blog_entry GET /admin_blog_entries/:id.:format {:controller=>"admin_blog_entries", :action=>"show"}
PUT /admin_blog_entries/:id {:controller=>"admin_blog_entries", :action=>"update"}
PUT /admin_blog_entries/:id.:format {:controller=>"admin_blog_entries", :action=>"update"}
DELETE /admin_blog_entries/:id {:controller=>"admin_blog_entries", :action=>"destroy"}
DELETE /admin_blog_entries/:id.:format {:controller=>"admin_blog_entries", :action=>"destroy"}
home / {:action=>"index", :controller=>"index"}
/:controller/:action/:id
/:controller/:action/:id.:format
看起来不对。这是my routes.rb(删除注释):
ActionController::Routing::Routes.draw do |map|
map.resources :admin_blog_entries
map.home '', :controller => 'index'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end