Modified: trunk/app/controllers/reviews_controller.rb (2506 => 2507)
--- trunk/app/controllers/reviews_controller.rb 2010-09-06 15:07:22 UTC (rev 2506)
+++ trunk/app/controllers/reviews_controller.rb 2010-09-07 10:19:58 UTC (rev 2507)
@@ -134,13 +134,15 @@
@reviewable = workflow
else
if logged_in?
- error("Workflow not found (id not authorized)", "is invalid (not authorized)", :workflow_id)
+ error("Workflow not found (id not authorized)", "is invalid (not authorized)")
+ return false
else
find_reviewable_auth if login_required
end
end
rescue ActiveRecord::RecordNotFound
- error("Workflow not found", "is invalid", :workflow_id)
+ error("Workflow not found", "is invalid")
+ return false
end
end
@@ -153,6 +155,7 @@
@review = review
else
error("Review not found", "is invalid")
+ return false
end
end
@@ -161,17 +164,29 @@
@review = review
else
error("Review not found or action not authorized", "is invalid (not authorized)")
+ return false
end
end
private
- def error(notice, message, attr=:id)
+ def error(notice, message, attr = nil)
flash[:error] = notice
- (err = Review.new.errors).add(attr, message)
+
+ workflow_id_attr = attr
+ workflow_id_attr = :id if workflow_id_attr.nil?
+
+ (err = Review.new.errors).add(workflow_id_attr, message)
respond_to do |format|
- format.html { redirect_to reviews_url(params[:workflow_id]) }
+ format.html {
+ if attr
+ redirect_to reviews_url(params[:workflow_id])
+ else
+ redirect_to workflows_url
+ end
+ }
end
end
end
+