All posts in category Ruby On Rails

Rails Playground Add rails app into subdomain

Create your subdomain using your cpanel. For instance ‘staging’. ssh into your account. cd into your www directory mv staging staging.back now link your public directory from your new rails app to ‘staging’ ln -s /home/username/newapp/public /home/username/www/staging make sure file and folder permissions are set staging should be 777.

Rails Playground kill fcgi process

From ssh ( you’ll need to ask for this to be enabled. ) pkill -9 dispatch.fcgi Ignore the warning only your process will be killed.

Rails Eager Loading

Loading associated models together in far fewer queries using egar loading. Each User has one state, Has many Properties each property Has many images, has many pdfs, has one state >> u = User.find(120, :include => [:state,{:properties => [:images,:pdfs,:state]}])

Currency and Number formatting Rails

API link to Number and Currency formatting methods in rails. Examples number_to_currency(1234567890.50) # => $1,234,567,890.50 number_to_currency(1234567890.506) # => $1,234,567,890.51 number_to_currency(1234567890.506, :precision => 3) # => $1,234,567,890.506 number_to_currency(1234567890.506, :locale => :fr) # => 1 234 567 890,506 € number_to_currency(1234567890.50, :unit => “£”, :separator => “,”, :delimiter => “”) # => £1234567890,50 number_to_currency(1234567890.50, :unit => “£”, :separator [...]

Installing different versions of Rails

gem install -v 1.2.3 rails –include-dependencies

Install Rails without rdoc or ri

sudo gem install rails –no-rdoc –no-ri Works for all gem’s.

Installing git based plugin’s for Rails

Download and install Git and use the following command inside your Application folder. cd vendor/plugins git clone -q git://github.com/tecnoweenie/attachment_fu.git Installs the Attachment Fu plugin for Rails.