[logaling-commit] logaling/logaling-server [only_production_mode_needs_base_url] Read ENV['BASE_URL'] only in production mode

Zurück zum Archiv-Index

SHIMADA Koji null+****@clear*****
Tue Oct 16 15:56:41 JST 2012


SHIMADA Koji	2012-10-16 15:56:41 +0900 (Tue, 16 Oct 2012)

  New Revision: 63152f44b8abda79a9cf1ce862693073e87a083a
  https://github.com/logaling/logaling-server/commit/63152f44b8abda79a9cf1ce862693073e87a083a

  Log:
    Read ENV['BASE_URL'] only in production mode

  Modified files:
    app/helpers/application_helper.rb
    app/views/layouts/application.html.haml

  Modified: app/helpers/application_helper.rb (+8 -0)
===================================================================
--- app/helpers/application_helper.rb    2012-10-16 15:03:11 +0900 (5bb971a)
+++ app/helpers/application_helper.rb    2012-10-16 15:56:41 +0900 (0cb4573)
@@ -1,4 +1,12 @@
 module ApplicationHelper
+  def base_url
+    if Rails.env.production?
+      ENV['BASE_URL']
+    else
+      "http://#{request.host_with_port}"
+    end
+  end
+
   def render_sinpped(snipped, tag=:strong)
     buffer = ""
     snipped.each do |component|

  Modified: app/views/layouts/application.html.haml (+2 -2)
===================================================================
--- app/views/layouts/application.html.haml    2012-10-16 15:03:11 +0900 (263a67f)
+++ app/views/layouts/application.html.haml    2012-10-16 15:56:41 +0900 (0099d7b)
@@ -6,8 +6,8 @@
     %meta{:name => 'viewport', :content => 'width=device-width'}
     %meta{:property => "og:site_name", :content => "logalingけんさく"}
     %meta{:property => "og:title", :content => ['logalingけんさく', @title].flatten.compact.join(' | ')}
-    %meta{:property => "og:url", :content => ENV['BASE_URL']+request.path_info}
-    %meta{:property => "og:image", :content => ENV['BASE_URL']+image_path('commonLogo.png')}
+    %meta{:property => "og:url", :content => base_url+request.path_info}
+    %meta{:property => "og:image", :content => base_url+image_path('commonLogo.png')}
     = csrf_meta_tags
     / Le HTML5 shim, for IE6-8 support of HTML elements
     /[if lt IE 9]
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the logaling-commit mailing list
Zurück zum Archiv-Index