Ruby Reference
This is a simple page serving as a one stop reference for Ruby-related commands and tools.
Update: I’ve put up a comprehensive site of Ruby and Ruby on Rails resources at RubyMatters.com
Ruby on Rails
External Resources
- Irb Tips and Tricks
- Pragmatic Wiki - Rails Playtime - discussion and code from the book “Agile Web Development with Rails”, second edition.
to upgrade rails…
sudo gem update rails --include-dependencies
to create a new app…
rails name_of_app
to create a controller…
ruby script/generate controller controller_name
to test an app configuration including db connectivity…
rake db:migrate
to create a model…
ruby script/generate model model_name
to migrate model changes to the db…
rake db:migrate
to add a migration (such as adding columns)…
ruby script/generate migration add_price
to add scaffolding to a controller…
[syntax,add_scaffold.rb,ruby]
to create static scaffold…
ruby script/generate scaffold product admin
to create a db table for storing session data…
rake db:sessions:create
to delete all data from a db table…
rake db:sessions:clear
an example of a migration with foreign keys defined…
[syntax,migration_foreign_keys.rb,ruby]
defining a one-to-many relationship in the model…
[syntax,one-to-many.rb,ruby]
to create api docs…
rake doc:rails
to delete previous versions of libraries RubyGems installs…
gem cleanup
start the interactive Ruby shell (irb)…
ruby script/console
after installing a new version of Rails it may be a good idea to update supporting files for the app…
rake rails:update
WEBrick
to start…
ruby script/server
Mongrel
to install from a Rails project root…
sudo gem install mongrel --include-dependencies
to start…
mongrel_rails start -d
to stop…
mongrel_rails stop
