Archive for March, 2011

installing ruby & rubyOnRails in ubuntu

March 5, 2011

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:

  1. 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

  2. add some libs and gems.. for mysql support
    sudo apt-get install libmysqlclient-dev
    gem install mysql2
  3. 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
  4. create the databases for your project
    cd your_app_path
    rake db:create

    #it will create 2 databases – for development and for tests

alt print screen in ubuntu

March 4, 2011

it seems it does not work from the box

so, in oder to fix that type the command

sudo sysctl -w kernel.sysrq=0

This will disable “SysRq” key, which use the Alt+PrtScn.

ruby on rails – first steps

March 3, 2011

The first link which i’ve use:
http://www.jetbrains.com/ruby/documentation/

so, there are some useful shortcuts:

Crtl+Alt+G – open dialog with code-generators (like scaffold)

Ctrl+Alt+R – open dialogs with scripts/tasks to run (like db:create, db:migrate)


%d bloggers like this: