# Ubuntu 12.04 Ruby on Rails Development Environment I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go. As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind. ## Step 1: Get the repos ready and run updates. sudo apt-get update && sudo apt-get upgrade ## Step 2: Add required applications. sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion ruby ncurses-term mercurial ruby-dev exuberant-ctags libnotify-bin curl autoconf make automake ssh openjdk-6-jdk git-core git-doc imagemagick postgresql-contrib libpq-dev postgresql pgadmin3 vim vim-rails vim-gnome ## Step 3: Configure github, because you know everyone is using github. git config --global user.name git-username git config --global user.email git-email-address ssh-keygen -t rsa -C git-email-address If you have a github account, you should already know how to add the key that you just generated to your github account. If you don't, please consult github as their documentation is better than mine is. LINK ## Step 4: Install RVM, Ruby and Rails This one has actually changed a little bit. You can really go about things the same way as you always did, however you can also run one command and install rvm, ruby 1.9.3 and the latest version of rails, which at the time of this post was 3.2.6. curl -L https://get.rvm.io | bash -s stable --rails echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc source .bashrc That's kind of it. You've got a running development environment, but I never stop with just the minimum, and neither should you! ##Step 5: Install some other gems You don't need all of these, and most likely, you'll include them in your gemfile for the application you want to use them in, and that's probably the right way, but I usually use these on one app or another that I"m working on, so I'm including them here for reference. MY COOL GEM LIST heroku taps guard guard-rails guard-test guard-livereload pg capistrano rvm-capistrano devise cancan paperclip formtastic delayed_job rails_admin contact_us qwandry twitter-bootstrap-rails ZURB-foundation annotate pry prawn ## Step 6: Setting up postgres for your rails app access At this point, postgresql is set up, however you will need to also configure it for each application that you wish to host on postgresql, so the following steps you will need to repeat for each new application. sudo su postgres # Create a role for your application # # Substitute myapp with your app name and password with your password # # Semi-colons are important! # psql template1 #starts Postgres interactive shell create role myapp with createdb login password '_password_'; select * from pg_user; # Verify user created ("\q" to exit!) select * from pg_shadow; # sysid and password hash listed here \l # list databases \q # exit Postgres shell exit # exit "Postgres" admin user # Configure Postgres to use this user for your application # sudo gedit /etc/postgresql/9.1/main/pg_hba.conf Scroll down in this file and add the following just before: local all all ident local postgres myapp md5 local "myapp_development" myapp md5 local "myapp_test" myapp md5 local "myapp_production" myapp md5 Now, just restart postgres and make sure your database.yml and Gemfile.rb are configured correctly and you should be all set. sudo /etc/init.d/postgresql restart ### database.yml a rails app using Postgres ### development: adapter: postgresql encoding: unicode database: myapp_development pool: 5 host: localhost username: myapp password: password test: adapter: postgresql encoding: unicode database: myapp_test pool: 5 host: localhost username: myapp password: password production: adapter: postgresql encoding: unicode database: myapp_production pool: 5 host: localhost username: myapp password: password ### Add postgres to your Gemfile ### Add: gem 'pg' With this done, you should have a fully functioning rails development environment on ubuntu 12.04. At this point, assuming you've made all of the necessary substitutions, you should be able to go into your rails app and execute a rake db:create:all. But if you are interested in adding some more tools to your setup, and really get things moving using some of these extras! ### Development Extras #### Add Gedit-Gmate sudo apt-add-repository ppa:ubuntu-on-rails/ppa sudo apt-get update sudo apt-get install gedit-gmate #### Add Sublime Text 2 sudo add-apt-repository ppa:webupd8team/sublime-text-2 sudo apt-get update sudo apt-get install sublime-text-2-beta #### Add Retext 1.0 (markdown editor) sudo add-apt-repository ppa:mitya57 sudo apt-get update sudo apt-get install retext #### Configure Vim for Rails curl -Lo- https://bit.ly/janus-bootstrap | bash Add some bash aliases for ease of use I always add a few bash aliases that make my time at the command line a bit easier, but they only work if you know them, so if any of these appeal to you, feel free to add them, or add to them in the comments! To make the changes, just enter: gedit ~/.bashrc Then enter the following at the bottom of the file. alias b="bundle" alias bu="b update" alias be="b exec" alias compile="be rake assets:precompile" alias edit="sublime-text-2" function commit { be rake assets:precompile git add . read -p "Commit description: " desc git commit -m "$desc" git push } function newdb { be rake db:drop:all be rake db:create:all be rake db:setup be rake db:test:prepare } ## In conclusion... Be sure to check out the livereload plugin for your browser, if you installed the gem, it only makes sense to get it setup on your system. Plugins exist for both Firefox and Google Chrome, which are the two browsers that I use frequently on Ubuntu. If you've got any other tips or tools that you use while developing ruby on rails applications on an Ubuntu 11.10 platform, please feel free to add to the comments. Posted by Eric Proctor at 11:45 AM Labels: 12.04, how-to, precise pangolin, ruby on rails, ubuntu Source: http://www.rubypluspl.us/2012/06/ubuntu-1204-ruby-on-rails-development.html?utm_source=rubyweekly&utm_medium=email