Created
September 7, 2011 10:28
-
-
Save kaievns/1200232 to your computer and use it in GitHub Desktop.
RJS substitute for right-rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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