2
3渲染形式部分我有局部的命名空间和嵌套的资源一种形式,至今一直有疼痛感得到正常工作(“博客/职位/评论”)。我设法得到它的工作的“新”和“编辑”行为(在评论控制器),但现在我想将其加载到“显示”视图父控制器(职位)的。不过,我已经尝试过的任何东西都可以工Rails的在另一个控制器
这里是形式是如何在“/blog/comments/shared/_comment_form.html.erb”产生:
<%= form_for([:blog, @post, @comment],
:url => { :controller => :comments, :action => (@comment.persisted? ? :update : :create) },
:html => { :id => "blog_post_comment_form", :class => "standard_form wide" }) do |f| %>
我使用一个标准的尝试调用此部分的“渲染”命令,但我得到的其中最有可能与我产生了在上面的代码形式的URL的方式来做到以下错误:
No route matches {:action=>"create", :controller=>"blog/comments"}
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:425:in `raise_routing_error'
这里是我的路线:
blog_post_comments GET /blog/posts/:post_id/comments(.:format) {:controller=>"blog/comments", :action=>"index"}
POST /blog/posts/:post_id/comments(.:format) {:controller=>"blog/comments", :action=>"create"}
new_blog_post_comment GET /blog/posts/:post_id/comments/new(.:format) {:controller=>"blog/comments", :action=>"new"}
edit_blog_post_comment GET /blog/posts/:post_id/comments/:id/edit(.:format) {:controller=>"blog/comments", :action=>"edit"}
blog_post_comment GET /blog/posts/:post_id/comments/:id(.:format) {:controller=>"blog/comments", :action=>"show"}
PUT /blog/posts/:post_id/comments/:id(.:format) {:controller=>"blog/comments", :action=>"update"}
DELETE /blog/posts/:post_id/comments/:id(.:format) {:controller=>"blog/comments", :action=>"destroy"}
我一直在抨击我的头在墙上这一周了,因此任何帮助是极大的赞赏。谢谢!
你有一个'@ blog','渲染局部形式定义之前@ comment'对象? – rubyprince 2011-06-08 06:19:51
如果你的意思是在“@post”和“@comment”,他们是在控制器产生。 – 2011-06-08 14:51:30