My Notes on Ruby on Rails

I am by no means an expert in this. I'm writing these notes for myself, but if anyone else finds 'em useful, then they are welcome to them.

Shell Commands

  • rails: This is the command which creates new projects, etc. 'rails -d postgresql conversion' is what I used to create the initial files for my caliber conversion app.
  • rake: This is the command which is analogous to make. There are a lot of sub-steps, though. I found that running rake db:create:all helped considerably.
  • gem: This command is analogous to CPAN, minus the interactive shell. The Perl-impaired may find it easier to think of it as Ruby's version of yum or apt-get.

Notes on the Process

Being a former DBA, I find it easier to develop an application by first developing the database schema, then building the app around it. It turns out that this is more or less exactly what Ruby expects you to do. I had created it in a database called 'gunwiki', so I did 'pg_dump gunwiki | psql conversion_development', which is where Ruby is going to expect to find its objects. Apparently Ruby will look at the tables and automatically build classes from them.

Vocabulary notes

  • Tables: They are called 'scaffolds' in Ruby, and you create them by doing 'script/generate scaffold tablename'.

Teaching Ruby about the Schema

It's important to use 'rake db:schema:dump' to get Ruby to notice all the schema of the various tables in your database. You'll end up with 'db/schema.rb', which you can put into a migration. To create your migration, run 'script/generate migration BaseSchema', which will create your base schema for the application. You'll have to run 'rake db:migrate' after any migrations, before you can rebuild the application with 'rake'.

Development Notes

-- SeanNewton - 22 May 2008

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2008-06-14 - SeanNewton
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback