Working with Rails
Feb26Difficulty: 




In my previous post, I blogged about installing Ruby.
Ruby is the programming language. Rails is a collection of Ruby scripts.
Now let’s install Rails. – (Damn this is so easy!)
Just type in the command line (don’t worry it can take a while):
gem install rails --include-dependencies
This will auto install Rails with some documentation.
Now let’s start to create a Rails workfolder.
I want it something like this:
testProject
-app
-config
-db
-doc
-lib
-log
-public
-script
-test
-temp
-vendor
..README
..RakeFile
rails testProject
Done!
To install sqlite3 (database) for Ruby, just type:
gem install sqlite3-ruby --version 1.2.3
Creating a sqlite database is easy as well:
rake db:create:all ruby script\generate scaffold user first_name:string last_name:string address:text rake db:migrate
Now prefill this database with values:
ruby script\console lee = User.create(:first_name => 'lee', :last_name => 'boonstra', :address => 'Holland')
Do you want a more graphical tool, to view your database or run your queries? Use SQLiteManager.
To install gems for debugging ruby code (in for example Aptana):
gem install ruby-debug-ide
To install gems for Mongrel HTTP server:
gem install mongrel
Do you understand now, why developers love Ruby? It’s so handy and easy.
And I know more fun! Let’s create a Ruby webserver! (Again via the command line).
ruby script/server
Your webserver will be start, by default on port 3000.
Do you want a default port? Let’s say 8000?
ruby script/server -p 8000
Now go head! Let’s run your server: http://localhost:3000
Posted in ruby on rails |gems, / install rails, / install sqlite3, / learn ruby, / ruby, / ruby database, / teach ruby on rails
» Post your comment, there are no comments yet. »
Comments
- Pulkit Singhal
- Neil
- mike nittmann
- geniutrixone
- Mika
- Romfrosk
- steve
- shahzad
- Maurice
- Lee
- Oskar Krawczyk