Do not fail when JSON engine is not found

and fallback to default
This commit is contained in:
ccocchi 2012-07-26 16:44:51 +02:00
parent 6e5fc9c833
commit 8a49001b0f
3 changed files with 5 additions and 5 deletions

View File

@ -2,6 +2,7 @@
## 0.1.2 (unreleased) ## 0.1.2 (unreleased)
* Add RablRails#render method (see README or source code) * Add RablRails#render method (see README or source code)
* Fix fail when JSON engine is not found. Now fallback to MultiJson.default_adapter
## 0.1.1 ## 0.1.1

View File

@ -29,15 +29,13 @@ module RablRails
def self.configure def self.configure
yield self yield self
post_configure
end end
def self.cache_templates? def self.cache_templates?
ActionController::Base.perform_caching && @@cache_templates ActionController::Base.perform_caching && @@cache_templates
end end
private def self.set_conversion_engines!
def self.post_configure MultiJson.use(self.json_engine) rescue nil
MultiJson.engine = self.json_engine
end end
end end

View File

@ -3,6 +3,7 @@ module RablRails
initializer "rabl.initialize" do |app| initializer "rabl.initialize" do |app|
ActiveSupport.on_load(:action_view) do ActiveSupport.on_load(:action_view) do
ActionView::Template.register_template_handler :rabl, RablRails::Handlers::Rabl ActionView::Template.register_template_handler :rabl, RablRails::Handlers::Rabl
RablRails.set_conversion_engines!
end end
end end
end end