Poetry of Programming

Its about Ruby on Rails – Kiran Soumya

By

Rake Task in Rails 3 on Production ENV

Cannot execute Rake Task in production environment? Does it throws errors of uninitialized objects or refuses to load Model classes?

To execute a rake task for eager loading we require,
config.threadsafe! to be disabled in production which is enabled by default.

But our requirement is to get it disabled only on running a rake task.

Rake already sets a Ruby global: $rails_rake_task

So, in config/environments/production.rb, just say:

 config.threadsafe! unless $rails_rake_task

By

Installing RVM & Git through Proxy

RVM relies on GIT.

So set proxy for GIT first.

*  Set the http_proxy environment
*  Set a proxy command to bypass the connection:
gcc -o connect connect.c
mv connect ~/bin
echo “/home/kiran/bin/connect -H proxy.company.com:6030 $@” >> ~/bin/proxy
chmod +x ~/bin/proxy

echo “export GIT_PROXY_COMMAND=proxy” >> .bashrc

Now try git clone. If it doesnt work, try out the following the command.

export http_proxy=http://<username>:<password>@<proxy_ip>:<proxy_port>

This line below also works like a charm for GIT,

git config --global http.proxy proxy_addr:proxy_port

Once the GIT is configured, for RVM, you need to do one more change for curl,
Set the proxy inside your ~/.curlrc

proxy = proxy.company.com:proxy_port

and now you can install rvm with no issues.

For rvm install thru proxy:

rvm install X --proxy proxy.company.com:proxy_port

If two developers are under the same user-group, we can even clone/copy the .rvm folder within two users without explicit installations.

Some more references:
http://blog.iwkse.homeunix.org/index.php?/archives/9-Git-Basic-setup.html
http://beginrescueend.com/
http://zipizap.wordpress.com/2010/11/02/cloning-rvm-to-other-user-you-can-just-copy-the-rvm-directory/ [This worked for me as well]