Ubuntu 10.10, ruby 1.9.2, rubyonrails 3.0.x.
######### INSTALLING ##############
#First, let’s install all of the necessary tools and libraries:
apt-get install curl git-core build-essential zlib1g-dev libssl-dev libreadline5-dev
#Install ruby 1.9.2 using RVM. Refer to the official RVM instructions here. Make sure you have curl #and git installed (from above) and run this command:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
#Then add this line as the last line to your .bashrc:
source “$HOME/.rvm/scripts/rvm”
#Close your terminal and open a new one, then run the following to test your RVM’s installation:
rvm notes
#Next, you can begin ruby 1.9.2 installation by running:
rvm install 1.9.2
#The install will take up to several minutes and once it completes you have to set ruby 1.9.2 as the #default version:
rvm –default ruby-1.9.2
#Then you can test your new ruby install:ruby -v
#install railsgem install rails
#that’s all! (minimum settings)
######## GEM -PACKAGINGs #######
#RuvyGems – slike Maven repository or like apt-get in Ubuntu
# shows all gems (all plugins avaliable for RoR)
gem list –local
gem list –remote
#search by “STRING” in the remote repository
gem search STRING –remote
#do this just in case, and look at the output:
gem install rubygems-update
update_rubygems
######### CREATING AND LAUNCH A NEW APP #########
i may recommend to use rubymine ide, but you should know how create your app in command line:
rails new YOUR_APP_PATH
#start
cd YOUR_APP_PATH
rails server
#launch app
rails s
#or (if you want to set the port by yourself)
rails s –port 8080
#open your browser and type there – this is your aplication:
http://127.0.0.1:3000/
########### CHANGING DB for your app ###########
#i suppose you would like to work with mysql database instead of using default one (which is defined in your_app_path/config/database.yml )
so, in order to switch the db for your project, you should:
- edit tht file database.yml like this:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: myproject_development
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock#do it for all databases not only for development one (if you wish)
#by the way: Ruby on Rails recommends to create three databases
1. myproject_development
2. myproject_production
3. myproject_test - add some libs and gems.. for mysql support
sudo apt-get install libmysqlclient-dev
gem install mysql2 - add new line to your project’s folder
to file: Gemfile
line: gem ‘mysql2′
#it means that you are going to use this module/gem in your project - create the databases for your project
cd your_app_path
rake db:create
#it will create 2 databases – for development and for tests