2011-10-14 2 views
2

오랫동안 봤지만 제 문제에 대한 완전한 대답을 찾지 못했습니다.inherited_resources, 유효성 검사 오류로 렌더링하는 올바른 방법

내 응용 프로그램에서는 inherited_resources를 사용합니다. 그래서, 코멘트 개체의 succefull 작성 후 리디렉션 대체하려면, 그래서 쓰기 :

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을하지 않는 오류가 있습니다, 내가 show 액션의 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 %> 

답변

0

: 여기에 추가 정보 형태의 내 렌더링입니다. 어쨌든 감사합니다.