现在的位置: 首页 > 综合 > 正文

Set up professional rails3 develpment on ubuntu (part two)

2013年05月05日 ⁄ 综合 ⁄ 共 2851字 ⁄ 字号 评论关闭

This part I will lead you through the process of setting up RVM, GIT, MYSQL, VIM

Above all, lett's install some useful download tools:

aptitude : a better independence management tool than apt-get

sudo apt-get install aptitude

axel  : a fast multiply-lina downloader

sudo aptitude install axel

apt-fast : use aptitude and axel to install sofware, it is awesome!

sudo add-apt-repository ppa:apt-fast/stable
sudo aptitude update
sudo aptitude install apt-fast         

Then set up apt-fast follow the guaid 
   
      

(1)  Install the dependences

sudo apt-fast  install build-essential openssl libreadline6 libreadline6-dev 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 make ssh openjdk-6-jdk git-doc imagemagick  libpq-dev vim vim-rails vim-gnome nodejs mysql-server
libmysqlclient15-dev

(2)  Install the latest version of  RVM , Ruby 

curl -L https://get.rvm.io | bash -s stable

(3)   Add rvm function to bash

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
source .bashrc

(4)Install ruby and generate ri-file for the newly installed ruby (so you can use "ri xx" to reffer to the ruby api)

rvm install 1.9.3
rvm docs generate-ri 

(5) Configure gem not to generate ri and rdoc files, add the following line to ~/.gemrc

gem: --no-ri --no-rdoc

(6) Create gemset

rvm gemset create mygem
rvm use 1.9.3@mygem --default

(7) Install rails

gem install rails

(8)Create a rails app with mysql

rails g new myapp  -d mysql

(9)Configure database.yml

  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: myapp_development
  pool: 5
  username: root
  password: xxxx
  socket: /var/run/mysqld/mysqld.sock
  now you have successfully builded a rails app with mysql, just 'rails server' to try it!

(10) Configure git

git config --global user.name your-git-username
git config --global user.email your-git-email-address

(11) Create a git repot  and push it to github

cd myapp/
git init
git add .
git status
git  commit -m " first commit "

Then go to github, click "Create a New Repot" 


Fill in the name and then create


You get this line :


git remote add origin https://github.com/7LI/myapp.git
git push -u origin master

(The terminal shall ask you for github account name and password)

Flash the github page, you will see your codes already uploaded

(12)Publish on heruku

As with GitHub, when using Heroku you will need to
create SSH keys
if you haven’t already, and then tell Heroku your public key so that you can use Git to push the sample application repository up to their servers: ( ref => http://ruby.railstutorial.org/chapters/beginning?version=3.2#sec:1.4.1 )

Add to Gemfile:

group :prodcution do   gem 'activerecord-postgresql-adapter' end

Then

bundle install

gem install heroku
heroku keys:add
heroku create --stack cedar
git push heroku master
heroku rake db:migrate
 heroku open

(13) Configure vim for rails ( The janus : https://github.com/carlhuda/janus )

curl -Lo- https://bit.ly/janus-bootstrap | bash

g  Highly recommed the railscasts colorscheme

     Ibus input method is confict with gvim,  to handle it do the following:

echo 'alias gvim="gvim -f"' >> ~/.bashrc
source ~/.bashrc



抱歉!评论已关闭.