Monday, 12 March 2012

A Ruby on Rails developer environment

Ryan Bigg's explains how to install Rails, I trust him
Then you'll need postgres
echo "-d=postgresql --skip-bundle -T" > ~/.railsrc
# $ rvm gemset create opera_wbe
# $ gem install bundler --no-rdoc --no-ri
NOTE: the `-T` option will change the `config/application.rb` as this following top group instead of loading `rails/all` (very nice!):
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"

module OperaWbe
  class Application < Rails::Application
    # migration with numbers (001, 002, ...) in stead of timestamp
    config.active_record.timestamped_migrations = false

    # in production actually
    # prepend assets path
    # config.action_controller.asset_host = ASSETS_PATH

    # in development actually
    # Remove assets logging
    config.assets.logger = false # ~only~ one line each asset request

# [...]
Also I find the following files very useful
~/.irbrc                     # with global functions to call in the console
~/workspace/.rvmrc           # which loads my @new gemset
~/workspace/every_app/.rvmrc # with the following...
rvm ruby-1.9.2-p290@new # with bundler and rails only
rvm gemdir              # show the gemdir everytime you change project
# .irbrc
puts 'Using irb console helper functions from ~/.irbrc'

# returns the list of methods not inherited from Object
# it will not show methods overwritten from `Object.new`
# eg: `y ml String.new`
def ml(object)
  (String.public_methods - object.methods).sort
end
Then my prompt looks like this:
21:43:02-6950 - ~/workspace> cat ~/.bashrc
[...]
 # some more ls aliases
 alias ll='ls -l'
 alias la='ls -A'
        alias lo='ls -o'


# colorful, with time, history id and path (also in window title)
# export PS1="\[\e]0;\w\a\]\e[1;36m\t-\! - \w>\e[m "
export PS1="\[\e]0;\w\a\e[1;36m\]\t-\! - \w>\[\e[m\] "
# TODO: git branch in prompt


# ror workspace available everywhere
export CDPATH=$CDPATH':/home/erik/workspace/'

## big bash history
export HISTSIZE=20000
# append all commands to the history file, don't overwrite it at the start of every new session
shopt -s histappend

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.
cd .
And yes, I know, at the moment without without the git branch, it's messing with the color.
echo 'gem: --no-ri --no-rdoc' >~/.gemrc # never install gem doc
A couple of config for git, get the book here
[color]
 diff = true
 status = true
 branch = true

[alias]
 co = checkout

Setup Sublime Text and customize it as such

No comments:

Post a Comment