Skip to content

Instantly share code, notes, and snippets.

@kaievns
Created September 7, 2011 10:28
Show Gist options
  • Save kaievns/1200232 to your computer and use it in GitHub Desktop.
Save kaievns/1200232 to your computer and use it in GitHub Desktop.
RJS substitute for right-rails
#
# RJS handler was kicked out of Rails 3.1 along with Prototype
# so, here is a little substitute coz we use it here and there
#
# Just save it in some file in the `config/initializers`
#
module ActionView
module Template::Handlers
class RJS
# Default format used by RJS.
class_attribute :default_format
self.default_format = Mime::JS
def call(template)
"update_page do |page|;#{template.source}\nend"
end
end
end
end
ActiveSupport.on_load(:action_view) do
ActionView::Base.class_eval do
cattr_accessor :debug_rjs
self.debug_rjs = false
end
ActionView::Template.register_template_handler :rjs, ActionView::Template::Handlers::RJS.new
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment