Skip to main content

How to Install and Use Edge Rails?

How to Install and Use Edge Rails?


1.  If you want to freeze your application to the gems version currently available on your system, then go to root of your rails application and run

rake rails:freeze:gems

By running the above command a new directory “rails” will be created inside your vendors directory. When you run your rails framework, Your application will first check for this directory and if it’s present, Rails components will be loaded from this directory instead of using your system copy of rails, and thus you are switched from Gems Rails to Edge Rails.

2.  If at any point of time, you want to switch back from Edge Rails to Gem Rails. You can always do it by running the below command

rake rails:unfreeze

3. If you want to freeze your application to the latest development version, then run.

rake rails:freeze:edge

once you are switched to the latest development version, your javascripts and other configuration files needs to be updated corresponding to the latest version. For this you need to run,

rake rails:update

4. Freeze your application to a different version.
Consider you want to freeze your rails application to rails version 2.1.0, then you have to just run the command

rake rails:freeze:edge RELEASE=2.1.0

5. In order to find out what version of rails your application uses, From the  root of your rails application, run

script/about

your output will be something like below.

About your application’s environment
Ruby version              1.8.6 (i686-linux)
RubyGems version          1.1.1
Rails version             2.1.0
Active Record version     2.1.0
Action Pack version       2.1.0
Active Resource version   2.1.0
Action Mailer version     2.1.0
Active Support version    2.1.0
Edge Rails revision       unknown
Application root          your application path
Environment               development
Database adapter          mysql
Database schema version   20090622125330
Loaded suite script/about
Started

Finished in 0.000606 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

6. Installing all other application depending gems locally.

1. Consider your application require the following two gems

a) will_paginate
b) mini_magick

Now go to your config/environment.rb file and config the required gems  as  below.

Rails::Initializer.run do |config|
config.gem “mini_magick”
config.gem “will_paginate”
end

2. Now consider these gems are not yet installed in your local machine. In order to install the above gems in your local machine,  from the root of your application run

rake gems:install

If you have already installed the above gems at some point of time, then skip this step and proceed to next step.

3. Now In order to make the above gems application-dependent rather than system-dependent gems. You need to unpack all these gems inside your application using

rake gems:unpack

The above command will create a new directory “gems” inside your vendor folder and unpack the two gems “will_paginate” and “mini_magick” inside the “gems” directory.

4. Unpack gems individually

There are two ways to unpack the gems individually.

Either run this from the root of your application.

rake gems:unpack GEM=will_paginate

or

change your directory to /vendor/gems and run

gem unpack “gem_name”

Comments

Popular posts from this blog

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).?

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).) In rails?


1)change the gemfile in mysql version
 gem 'mysql2'

2)Change to mysql2 version
 gem 'mysql2','0.3.20'

Active Scaffold : Add radio buttons to your form ruby on rails ?

Active Scaffold : Add radio buttons to your form ruby on rails ?

The way to add radio buttons to your active scaffold create/update from is as shown below

#Controller

class UsersController < ApplicationController
active_scaffold :user do |config|
config.label = “Users”
config.columns = [:name, :gender]
config.columns[:gender].form_ui = :radio
config.columns[:gender].options[:options] = [['Male', '1'], ['Female','2']]
end
end

Get user accessing ip address in rails?

Get user accessing ip address rails?

request.ip ->returns the ip, whether is is a local proxy ip (localhost address) or not.
*request.remote_ip -> is smarter and gets the ip address of the client outside of local proxies.
3)If you are using apache in front of a mongrel, then remote_ip will return the source address of the request, which in this case will be local host because the Apache web server is making the request, so instead put this in your controller:

@remote_ip = request.env["HTTP_X_FORWARDED_FOR"]