myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2812] trunk/config/environment.rb: added version


From: noreply
Subject: [myexperiment-hackers] [2812] trunk/config/environment.rb: added version checking to truncate fix
Date: Wed, 16 Nov 2011 10:36:04 -0500 (EST)

Revision
2812
Author
dgc
Date
2011-11-16 10:36:04 -0500 (Wed, 16 Nov 2011)

Log Message

added version checking to truncate fix

Modified Paths

Diff

Modified: trunk/config/environment.rb (2811 => 2812)


--- trunk/config/environment.rb	2011-11-16 15:07:04 UTC (rev 2811)
+++ trunk/config/environment.rb	2011-11-16 15:36:04 UTC (rev 2812)
@@ -113,13 +113,15 @@
 load 'config/environment_private.rb' if FileTest.exist?('config/environment_private.rb')
 
 # Fix for Ruby 1.8.7 when using Rails < 2.2
-module ActionView
-  module Helpers
-    module TextHelper
-      def truncate(text, length = 30, truncate_string = "...")
-        if text.nil? then return end
-        l = length - truncate_string.chars.to_a.size
-        (text.chars.to_a.size > length ? text.chars.to_a[0...l].join + truncate_string : text).to_s
+if RUBY_VERSION == "1.8.7" && ((RAILS::VERSION::MAJOR == 1) || (RAILS::VERSION::MAJOR == 2 && RAILS::VERSION::MINOR < 2))
+  module ActionView
+    module Helpers
+      module TextHelper
+        def truncate(text, length = 30, truncate_string = "...")
+          if text.nil? then return end
+          l = length - truncate_string.chars.to_a.size
+          (text.chars.to_a.size > length ? text.chars.to_a[0...l].join + truncate_string : text).to_s
+        end
       end
     end
   end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]