Skip to content

Instantly share code, notes, and snippets.

@Panmind
Created July 21, 2010 09:36
Show Gist options
  • Save Panmind/484271 to your computer and use it in GitHub Desktop.
Save Panmind/484271 to your computer and use it in GitHub Desktop.
You already know: obtrusive Javascript is evil and clumsy
# Because obtrusive JavaScript is evil, and the Joe developer must not
# be able to introduce it with an "innocent" :method => :delete option
# passed to a link_to.
# (C) 2010 Panmind - Released in the Public Domain
#
helper = ActionView::Helpers::JavaScriptHelper
keep = %w(javascript_tag javascript_cdata_section escape_javascript)
keep.map!(&:to_sym) if RUBY_VERSION.to_f >= 1.9
methods = helper.public_instance_methods - keep
helper.class_eval do
methods.each do |meth|
undef_method meth
define_method(meth) do |*args|
raise NotImplementedError, 'This method is not available in this application'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment