Validation 继承的_资源,正确的呈现方式,存在验证错误

Validation 继承的_资源,正确的呈现方式,存在验证错误,validation,inherited-resources,rails-3.1,Validation,Inherited Resources,Rails 3.1,我在谷歌上搜索了很长时间,但没有找到问题的完整答案 在我的应用程序中,我使用继承的资源。所以,我想在成功创建注释对象后覆盖重定向,所以我写: update! do |success, failure| success.html { redirect_to parent_url } end update! do |success, failure| success.html { redirect_to parent_url } failure.html { add_brea

我在谷歌上搜索了很长时间,但没有找到问题的完整答案

在我的应用程序中,我使用继承的资源。所以,我想在成功创建注释对象后覆盖重定向,所以我写:

update! do |success, failure|
  success.html { redirect_to parent_url }
end
update! do |success, failure|
  success.html { redirect_to parent_url }
  failure.html { 
    add_breadcrumb t("share.Home"), root_path
    add_breadcrumb t("project.Projects"), projects_path
    ...
    add_breadcrumb t("comment.edit_comment"), edit_resource_url
    render :action => :edit and return }
 end
我知道我可以在一个字符串中完成,但我需要阻塞,因为当失败发生时,我也需要添加操作。所以我写:

update! do |success, failure|
  success.html { redirect_to parent_url }
end
update! do |success, failure|
  success.html { redirect_to parent_url }
  failure.html { 
    add_breadcrumb t("share.Home"), root_path
    add_breadcrumb t("project.Projects"), projects_path
    ...
    add_breadcrumb t("comment.edit_comment"), edit_resource_url
    render :action => :edit and return }
 end
当一切正常时,它会正确重定向,但有任何错误,我没有得到编辑操作的URL,我有显示操作URL,但会显示编辑表单和错误。这样行吗,还是我做错了什么? 以下是我对表格的呈现,以获取更多信息:

<% link = "project_#{@comment.commentable_type.downcase}_comment_path"%>
<%= semantic_form_for [@project,@comment.commentable,@comment], :validate => true, :url => send(link,@project,@comment.commentable,@comment), do |f| %>
  <%= render 'form', :f => f %>
<% end %>

true,:url=>send(链接,@project,@comment.comment,@comment),do | f |%>
f%>

如果没有答案,我认为这没问题,可能是render是render,但操作已经完成,URL已更改。无论如何,谢谢。

如果没有答案,我认为这没问题,可能呈现就是呈现,但操作已经完成,URL已更改。无论如何,谢谢