Tweets about "ruby on rails"
PART A Getting Started with ruby
[STEP 1] install ruby with RVM("Ruby Version Manager")
prayag@prayag:~$ curl -L get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 185 100 185 0 0 11 0 0:00:16 0:00:16 --:--:-- 298
100 10237 100 10237 0 0 428 0 0:00:23 0:00:23 --:--:-- 4784
Downloading RVM from wayneeseguin branch stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 125 100 125 0 0 53 0 0:00:02 0:00:02 --:--:-- 65
100 1123k 100 1123k 0 0 33460 0 0:00:34 0:00:34 --:--:-- 56459
Installing RVM to /home/prayag/.rvm/
Adding rvm PATH line to /home/prayag/.bashrc /home/prayag/.zshenv.
Adding rvm loading line to /home/prayag/.bash_profile /home/prayag/.zprofile.
# RVM: Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm/
# Screencast: http://screencasts.org/episodes/how-to-use-rvm
# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'
Installation of RVM in /home/prayag/.rvm/ is almost complete:
* To start using RVM you need to run `source /home/prayag/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
# iPrayag,
#
# Thank you for using RVM!
# I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne
[STEP 2] ensure that changes to the environment made in .profile affect the current shell
prayag@Prayag:~$ ls -l .rvm/scripts/
total 372
-rwxrwxr-x 1 prayag prayag 5671 Jan 25 11:20 alias
-rw-rw-r-- 1 prayag prayag 97 Jan 25 11:20 aliases
-rwxrwxr-x 1 prayag prayag 2602 Jan 25 11:20 base
-rwxrwxr-x 1 prayag prayag 3389 Jan 25 11:20 cd
-rwxrwxr-x 1 prayag prayag 2289 Jan 25 11:20 cleanup
-rwxrwxr-x 1 prayag prayag 33683 Jan 25 11:20 cli
-rwxrwxr-x 1 prayag prayag 1371 Jan 25 11:20 color
-rwxrwxr-x 1 prayag prayag 2785 Jan 25 11:20 completion
-rwxrwxr-x 1 prayag prayag 1407 Jan 25 11:20 cron
-rwxrwxr-x 1 prayag prayag 1628 Jan 25 11:20 db
-rwxrwxr-x 1 prayag prayag 1256 Jan 25 11:20 default
-rwxrwxr-x 1 prayag prayag 2140 Jan 25 11:20 disk-usage
-rwxrwxr-x 1 prayag prayag 3720 Jan 25 11:20 docs
-rwxrwxr-x 1 prayag prayag 508 Jan 25 11:20 env
-rwxrwxr-x 1 prayag prayag 14978 Jan 25 11:20 external
drwxrwxr-x 2 prayag prayag 4096 Jan 25 11:20 extras
-rwxrwxr-x 1 prayag prayag 3680 Jan 25 11:20 fetch
drwxrwxr-x 5 prayag prayag 4096 Jan 25 11:20 functions
-rwxrwxr-x 1 prayag prayag 28401 Jan 25 11:20 gemsets
-rwxrwxr-x 1 prayag prayag 473 Jan 25 11:20 get
-rwxrwxr-x 1 prayag prayag 1194 Jan 25 11:20 group
-rwxrwxr-x 1 prayag prayag 1120 Jan 25 11:20 hash
-rwxrwxr-x 1 prayag prayag 1468 Jan 25 11:20 help
-rwxrwxr-x 1 prayag prayag 978 Jan 25 11:20 hook
-rwxrwxr-x 1 prayag prayag 5688 Jan 25 11:20 info
-rwxrwxr-x 1 prayag prayag 6236 Jan 25 11:20 initialize
-rwxrwxr-x 1 prayag prayag 2675 Jan 25 11:20 install
-rw-rw-r-- 1 prayag prayag 406 Jan 25 11:20 irbrc
-rw-rw-r-- 1 prayag prayag 2540 Jan 25 11:20 irbrc.rb
-rwxrwxr-x 1 prayag prayag 8967 Jan 25 11:20 list
-rwxrwxr-x 1 prayag prayag 7356 Jan 25 11:20 maglev
-rwxrwxr-x 1 prayag prayag 660 Jan 25 11:20 manage
-rwxrwxr-x 1 prayag prayag 5467 Jan 25 11:20 migrate
-rwxrwxr-x 1 prayag prayag 2864 Jan 25 11:20 monitor
-rwxrwxr-x 1 prayag prayag 6422 Jan 25 11:20 notes
-rwxrwxr-x 1 prayag prayag 565 Jan 25 11:20 override_gem
-rwxrwxr-x 1 prayag prayag 1472 Jan 25 11:20 patches
-rwxrwxr-x 1 prayag prayag 851 Jan 25 11:20 patchsets
-rwxrwxr-x 1 prayag prayag 1504 Jan 25 11:20 pkg
-rwxrwxr-x 1 prayag prayag 4055 Jan 25 11:20 repair
-rwxrwxr-x 1 prayag prayag 1325 Jan 25 11:20 requirements
-rwxrwxr-x 1 prayag prayag 297 Jan 25 11:20 rtfm
-rwxrwxr-x 1 prayag prayag 6261 Jan 25 11:20 rubygems
-rwxrwxr-x 1 prayag prayag 4912 Jan 25 11:20 rvm
-rwxrwxr-x 1 prayag prayag 33836 Jan 25 11:20 selector
-rwxrwxr-x 1 prayag prayag 4482 Jan 25 11:20 selector_gemsets
-rwxrwxr-x 1 prayag prayag 5647 Jan 25 11:20 set
-rwxrwxr-x 1 prayag prayag 7570 Jan 25 11:20 snapshot
-rwxrwxr-x 1 prayag prayag 5736 Jan 25 11:20 tools
-rwxrwxr-x 1 prayag prayag 3772 Jan 25 11:20 upgrade
-rwxrwxr-x 1 prayag prayag 550 Jan 25 11:20 version
-rwxrwxr-x 1 prayag prayag 4602 Jan 25 11:20 wrapper
drwxrwxr-x 3 prayag prayag 4096 Jan 25 11:20 zsh
prayag@prayag:~$ source /home/prayag/.rvm/scripts/rvm
Check rvm version
prayag@prayag:~$ rvm --version
rvm 1.16.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
[STEP 3] install ruby 1.9.3 from available list
prayag@prayag:~$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7-p370
[ruby-]1.8.7[-p371]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2-p180
[ruby-]1.9.2-p290
[ruby-]1.9.2-p318
[ruby-]1.9.2[-p320]
[ruby-]1.9.2-head
[ruby-]1.9.3-preview1
[ruby-]1.9.3-rc1
[ruby-]1.9.3-p0
[ruby-]1.9.3-p125
[ruby-]1.9.3-p194
[ruby-]1.9.3-[p286]
[ruby-]1.9.3-head
ruby-head
prayag@prayag:~$ source ~/.bash_profile
prayag@prayag:~$ rvm install 1.9.3
ruby-1.9.3-p286 - #configure
ruby-1.9.3-p286 - #download
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5061k 100 5061k 0 0 30425 0 0:02:50 0:02:50 --:--:-- 18902
ruby-1.9.3-p286 - #extract
ruby-1.9.3-p286 - #validate
ruby-1.9.3-p286 - #setup
'ruby' was not found, cannot install rubygems unless ruby is present (Do you have an RVM ruby installed & selected?)
Saving wrappers to '/home/prayag/.rvm/bin'.
ruby-1.9.3-p286 - #importing default gemsets (/home/prayag/.rvm/gemsets/)
[STEP 4] Use the newly installed ruby
prayag@prayag:~$ rvm use 1.9.3
Using /home/prayag/.rvm/gems/ruby-1.9.3-p286
check this worked correctly
prayag@prayag:~$ ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]
prayag@prayag:~$ which ruby;
/home/prayag/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
prayag@prayag:~$ rvm use 1.9.3 --default
Using /home/prayag/.rvm/gems/ruby-1.9.3-p286
[STEP 5]
$ sudo apt-get install libsqlite3-dev
To update ruby version later,
$ rvm get stable
$ rvm upgrade 2.0.0
$ rvm use 2.0.0
REFERENCES
http://junaidpven.wordpress.com/2011/10/25/how-to-install-ruby-and-rails-with-rvm-in-ubuntu-11-10/
PART B Getting Started with Rails
[STEP 1] install rails using the gem install command provided by RubyGems (may take some time)
Rubygems is a package manager for ruby.
prayag@prayag:~$ gem install rails
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.3.6.gem (100%)
Fetching: activesupport-3.2.8.gem (100%)
Fetching: builder-3.0.4.gem (100%)
Fetching: activemodel-3.2.8.gem (100%)
...........
....................
...........................
[STEP 2] verify, everything is installed correctly
prayag@prayag:~$ rails --version
Rails 3.2.8
Check for issue Installed Rails but the rails command says it's not installed
[STEP 3] create an app
prayag@prayag:~$ sudo mkdir workspace_rails
prayag@prayag:~$ sudo chmod 777 /home/prayag/workspace_rails/
prayag@prayag:~/workspace_rails$ rails new Gwitter
[STEP 4] structure of Gwitter rails app
prayag@prayag:~/workspace_rails$ cd Gwitter/
prayag@prayag:~/workspace_rails/Gwitter$ ls -l
total 68
drwxrwxr-x 8 prayag prayag 4096 Oct 30 12:21 app
drwxrwxr-x 5 prayag prayag 4096 Oct 30 12:21 config
-rw-rw-r-- 1 prayag prayag 157 Oct 30 12:21 config.ru
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 db
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 doc
-rw-rw-r-- 1 prayag prayag 765 Oct 30 12:21 Gemfile
drwxrwxr-x 4 prayag prayag 4096 Oct 30 12:21 lib
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 log
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 public
-rw-rw-r-- 1 prayag prayag 272 Oct 30 12:21 Rakefile
-rw-rw-r-- 1 prayag prayag 9208 Oct 30 12:21 README.rdoc
drwxr-xr-x 2 prayag prayag 4096 Oct 30 12:21 script
drwxrwxr-x 7 prayag prayag 4096 Oct 30 12:21 test
drwxrwxr-x 3 prayag prayag 4096 Oct 30 12:21 tmp
drwxrwxr-x 4 prayag prayag 4096 Oct 30 12:21 vendor
The structure of app
prayag@prayag:~/workspace_rails/Gwitter/app$ ls -l
total 24
drwxrwxr-x 5 prayag prayag 4096 Oct 30 12:21 assets
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 controllers
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 helpers
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 mailers
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 models
drwxrwxr-x 3 prayag prayag 4096 Oct 30 12:21 views
[STEP 5] make some changes in Gwitter/public/index.html
I made some changes in header div.
<div id="header">
<h1>Gwitter</h1>
<h2>Watch your favourite games live!</h2>
</div>
[STEP 6] Configure database
prayag@prayag:~/workspace_rails/Gwitter$ ls -l config
total 32
-rw-rw-r-- 1 prayag prayag 2812 Oct 30 12:21 application.rb
-rw-rw-r-- 1 prayag prayag 191 Oct 30 12:21 boot.rb
-rw-rw-r-- 1 prayag prayag 576 Oct 30 12:21 database.yml
-rw-rw-r-- 1 prayag prayag 151 Oct 30 12:21 environment.rb
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 environments
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 initializers
drwxrwxr-x 2 prayag prayag 4096 Oct 30 12:21 locales
-rw-rw-r-- 1 prayag prayag 1790 Oct 30 12:21 routes.rb
Change database.yml
prayag@prayag:~/workspace_rails/Gwitter$ sudo vi config/database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
[STEP 7] start a WEBrick server
prayag@prayag:~/workspace_rails/Gwitter$ rails server
/home/prayag/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr/local/sbin in PATH, mode 040777
/home/prayag/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr/local/sbin in PATH, mode 040777
=> Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[STEP 8]
Goto browser, hit http://localhost:3000/
No comments:
Post a Comment