diff app/helpers/application_helper.rb @ 437:d31fe32da7a0

Finish updating to rails 5
author nanaya <me@myconan.net>
date Sat, 02 Jul 2016 17:04:25 +0900
parents 851432f21603
children 68231013b01b
line wrap: on
line diff
--- a/app/helpers/application_helper.rb	Mon Jun 13 15:07:38 2016 +0900
+++ b/app/helpers/application_helper.rb	Sat Jul 02 17:04:25 2016 +0900
@@ -11,4 +11,10 @@
   def error_class(object, attribute)
     "has-error" if object.errors.include? attribute
   end
+
+  def with_host(url)
+    return url if url[0] != "/"
+
+    "#{request.protocol}#{request.host_with_port}#{url}"
+  end
 end