Turn RJS debugging on by default and show the source code when an exception is caught [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4003 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 1aff68d6
...@@ -433,8 +433,9 @@ module GeneratorMethods ...@@ -433,8 +433,9 @@ module GeneratorMethods
def to_s #:nodoc: def to_s #:nodoc:
returning javascript = @lines * $/ do returning javascript = @lines * $/ do
if ActionView::Base.debug_rjs if ActionView::Base.debug_rjs
javascript.replace "try {\n#{javascript}\n} catch (e) " source = javascript.dup
javascript << "{ alert('RJS error:\\n\\n' + e.toString()); throw e }" javascript.replace "try {\n#{source}\n} catch (e) "
javascript << "{ alert('RJS error:\\n\\n' + e.toString()); alert('#{source.gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }}'); throw e }"
end end
end end
end end
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
# Show full error reports and disable caching # Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.action_view.debug_rjs = true
# Don't care if the mailer can't send # Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册