Gem 1.5 with Rails 2.3 5

Posted by arunagw on March 19, 2011

You may fall down into the situation where you don’t have RVM and your system gem is upgraded for using latest things.

And your old application is still running on older version of rails.

This is just a workaround of using Gem > 1.3.7 in Rails 2.3 Applications.

I have tested this solution with Rails 2.3.5 and different version of gems.

After upgrading gems to 1.6.2 i have got an error

/activesupport-2.3.5/lib/active_support/dependencies.rb:55: 
uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)

To fix this error need to update boot.rb file. Place this at the top of boot.rb

require 'thread'

After adding this you should be getting this error

 
/gem_dependency.rb:119:in
 `requirement': undefined local variable or method `version_requirements'

To fix this error you need update your environment.rb file.
Add this code above your Rails::Initializer.run block.

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.3.7')
 module Rails
   class GemDependency
     def requirement
       r = super
       (r == Gem::Requirement.default) ? nil : r
     end
   end
 end
end

Now your application should start running properly. Have fun ;)

Now you can downgrade or upgrade your system gem version. Your application will still run.

Above workaround works for me very well. Any other ideas?

Redis key-value store 2

Posted by arunagw on March 18, 2011

Redis is really cool and lightweight key-value store. If you are looking for something in which you can store some string, hashes, lists, sets. TheĀ Redis is the best.

If you are a Ruby developer then you must try out this with a redis-rb gem. Very easy to configure, very easy to store things.

Following is the way of using redis in Ruby way.

To install

gem install redis

To load

require 'redis'

Before performing any operation with redis server you need to install Redis and start the redis server.

After that you can do like

redis = Redis.new # Automatically connect with the default port.

# if you have changed the port then you can specify the port in initialize.

>> redis.set "foo", "bar"
=> "OK"

>> redis.get "foo"
=> "bar"

Storing objects

>> redis.set "foo", [1, 2, 3].to_json
=> OK

>> JSON.parse(redis.get("foo"))
=> [1, 2, 3]

There are lot’s more things you can do with the Redis.

Links help you in redis

Redis official documentation (http://redis.io)
Github redis repository (https://github.com/antirez/redis)
Github redis rubygem repository (https://github.com/ezmobius/redis-rb)


Follow

Get every new post delivered to your Inbox

Join other followers