myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2788] trunk/config: Fixed incompatibilities when


From: noreply
Subject: [myexperiment-hackers] [2788] trunk/config: Fixed incompatibilities when using ruby 1.8. 7 with boot.rb and the truncate method
Date: Mon, 7 Nov 2011 12:07:04 -0500 (EST)

Revision
2788
Author
drn05r
Date
2011-11-07 12:07:04 -0500 (Mon, 07 Nov 2011)

Log Message

Fixed incompatibilities when using ruby 1.8.7 with boot.rb and the truncate method

Modified Paths

Diff

Modified: trunk/config/boot.rb (2787 => 2788)


--- trunk/config/boot.rb	2011-11-07 11:22:53 UTC (rev 2787)
+++ trunk/config/boot.rb	2011-11-07 17:07:04 UTC (rev 2788)
@@ -17,7 +17,7 @@
       end
 
     if rails_gem_version
-      rails_gem = Gem.cache.search('rails', "=#{rails_gem_version}.0").sort_by { |g| g.version.version }.last
+      rails_gem = Gem.cache.find_name('rails', "=#{rails_gem_version}.0").sort_by { |g| g.version.version }.last
 
       if rails_gem
         gem "rails", "=#{rails_gem.version.version}"

Modified: trunk/config/environment.rb (2787 => 2788)


--- trunk/config/environment.rb	2011-11-07 11:22:53 UTC (rev 2787)
+++ trunk/config/environment.rb	2011-11-07 17:07:04 UTC (rev 2788)
@@ -112,3 +112,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
+      end
+    end
+  end
+end

reply via email to

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