New RoR project cheat sheet

New project cheat sheet

Create project and bind to ruby/rails versions

Initialize  version control with  rvm

$ mkdir project-name

$ echo “rvm 1.9.3@project-name” > project-name/.rvmrc (or whatever version you want.)

$ cd project-name

answer the question with ‘y’ and create the gemset and reload rvm

$ rvm gemset create ‘project-name’

$ rvm reload


$ gem env gemdir

should give you



Create the Rails application

$ gem install rails –v 3.2.10 (or whatever version you want)

$ rails new .

$ gem install bundler

$ bundle install

Configure passenger/apache to work with rvm

If you have already done this on the server once, you should only have to copy the config/setup_load_paths.rb from one of the other directories, then run 
$ Bundle install –-path vendor/config
Other wise you will need to configure the server as described below.

Configure server for rvm

$ Bundle install –-path vendor/config

In app’s root dir before the apps will load.

Get project under version control

Create local repository

From  the root dir of the project

$ Git init

$ Git add  .

$ Git commit –m  “Initial commit”

Create the remote repository

ssh to remote machine (the git repository)
$ sudo su – git
$ cd /usr/local/git_root/

$ mkdir project-name.git
$ cd project-name.git/
$ git –bare init

Make sure the permissions are properly set

Exit the server

Add the remote repository

On the local machine (not the git repository)

$ git remote add origin ssh://git@ip:port/usr/local/git_root/project-name.git

$ git push -u origin master

Now should be all done! Get coding!

Leave a comment

Filed under Uncategorized

Snippet for finding empty has relationships

SELECT * FROM has_object WHERE id NOT IN (SELECT has_object_id FROM belongs_to);

Example company has many employees

SELECT * FROM company WHERE id NOT IN (SELECT company_id FROM employees);

Leave a comment

Filed under Uncategorized