verify :method => :post, :only => [ :create, :create_comment ], :redirect_to => { :action => :error_not_post }
def index
- reviews = Review.find :all, :conditions => ['rule_failure_id=?', params[:rule_failure_id]]
+ reviews = findReviewsForRuleFailure params[:rule_failure_id]
render :partial => "index", :locals => { :reviews => reviews }
end
@review.review_comments << @review_comment
if @review.valid?
@review.save
- #@reviews = Review.find :all, :conditions => ['rule_failure_id=?', @review.rule_failure_id]
- @reviews = findReviewsForRuleFailure @review.rule_failure_id
+ @reviews = findReviewsForRuleFailure @review.rule_failure_id
end
render "create_result"
end
return
end
- review_comment = ReviewComment.new(params[:review_comment])
- review_comment.user = current_user
- if review_comment.valid?
- review_comment.save
- index
- else
- @review_comment = review_comment
- @rule_failure_id = params[:rule_failure_id]
- # TODO Find a way to update the right DIV...
- render :partial => "form_comment"
+ @review_comment = ReviewComment.new(params[:review_comment])
+ @review_comment.user = current_user
+ @rule_failure_id = params[:rule_failure_id]
+ if @review_comment.valid?
+ @review_comment.save
+ @reviews = findReviewsForRuleFailure @rule_failure_id
end
+ render "create_comment_result"
end
private
<%= f.text_area :review_text, :rows => 10, :id => "commentText" + @review_comment.review_id.to_s %>
<br/>
<%= submit_to_remote 'create_btn', 'Add comment',
- :url => { :action => 'create_comment', :rule_failure_id => @rule_failure_id },
- :update => { :success => "reviewFailure" + @rule_failure_id.to_s } %>
+ :url => { :action => 'create_comment', :rule_failure_id => @rule_failure_id } %>
<%= submit_to_remote 'cancel_btn', 'Cancel',
:url => { :action => 'index', :rule_failure_id => @rule_failure_id.to_s },
:update => { :success => "reviewFailure" + @rule_failure_id.to_s } %>
--- /dev/null
+if @reviews
+ page.replace_html "reviewFailure" + @rule_failure_id.to_s, :partial => "index", :locals => { :reviews => @reviews }
+else
+ page.replace_html "createComment" + @review_comment.review_id.to_s, :partial => "form_comment"
+end
\ No newline at end of file