Parcourir la source

Add Oj to Ruby On Rails (#4508)

* Add Oj to Ruby On Rails

* Fix Date header in Ruby On Rails
Jonathan Vukovich-Tribouharet il y a 6 ans
Parent
commit
47f6c11579

+ 1 - 0
frameworks/Ruby/rails/Gemfile

@@ -7,3 +7,4 @@ gem 'activerecord-import', '0.27.0'
 gem 'activerecord', '5.2.2', :require => 'active_record'
 gem 'rails', '5.2.2'
 gem 'tzinfo-data', '1.2018.7'
+gem 'oj', '3.7.9'

+ 9 - 0
frameworks/Ruby/rails/app/controllers/application_controller.rb

@@ -1,2 +1,11 @@
 class ApplicationController < ActionController::Base
+
+  before_action :add_header
+
+protected
+
+  def add_header
+    response.set_header('Date', Time.now.httpdate)
+  end
+
 end

+ 1 - 1
frameworks/Ruby/rails/config/application.rb

@@ -27,6 +27,6 @@ module Hello
     # -- all .rb files in that directory are automatically loaded after loading
     # the framework and any gems in your application.
 
-    config.action_dispatch.default_headers.merge!('Date' => Time.now.httpdate, 'Server' => 'WebServer')
+    config.action_dispatch.default_headers.merge!('Server' => 'WebServer')
   end
 end

+ 1 - 0
frameworks/Ruby/rails/config/initializers/oj.rb

@@ -0,0 +1 @@
+Oj.optimize_rails