odie’s webmemory

Entries from November 2006

Eclipse, RDT and RadRails

November 20, 2006 · 1 Comment

I am tired of having multiple DOS windows and wordpad editors open all at the same time to work on my ruby on rails project. So I decided to download the Eclipse SDK, and the RDT (RubyEclipse Development) and RadRails plug-ins.

Installation:
1. Download Eclipse SDK and unzip into a directory.
2. Run Eclipse and use the update manager to install the plug-ins.
a. Go to Help -> Software Updates -> Find and Install …
b. Add the sites for the RDT and RadRails plug-ins (as listed in RadRails Update Sites)
i. RDT: http://updatesite.rubypeople.org/release
ii. RadRails: http://radrails.sourceforge.net/update

To use (with existing project):
1. Run Eclipse
2. Set the workspace to the parent directory of the Ruby on Rails project
3. Create a project file
a. File -> New -> Project -> Rails Project
b. Set the project name to the Ruby on Rails project directory

Links:
Eclipse SDK, http://www.eclipse.org/downloads
RDT – Ruby Eclipse Development, http://rubyeclipse.mktec.com/cgi-bin/trac.py/wiki
RadRails, http://www.radrails.org

Categories: rubyonrails

Format the datetime using StrFTime

November 17, 2006 · 1 Comment

To format a datetime, use StrFTime. For example to output the date in the following format “11/16/2006 11:58PM”, do the following: nowDT.strftime(“%m/%d/%y %I:%M%p”). nowDT is your datetime variable.

See the php documentation for further information. This also works for ruby on rails.

Categories: rubyonrails

Generate a model and a controller vs a scaffold

November 14, 2006 · 1 Comment

What do you get when you generate a scaffold instead of generating the model and the controller individually? Below are the excerpts (i.e., edited results) when I ran the generators with the -p option (pretend).

ruby script/generate model entry -p
create app/models/entry.rb
create db/migrate/001_create_entries.rb

ruby script/generate controller entry -p
create app/controller/entry_controller.rb

ruby script/generate scaffold entry entry -p
create app/models/entry.rb
create app/views/entry/_form.rhtml
create app/views/entry/list.rhtml
create app/views/entry/show.rhtml
create app/views/entry/new.rhtml
create app/views/entry/edit.rhtml
create app/controllers/entry_controller.rb
create app/views/layouts/entry.rhtml
create public/stylesheets/scaffold.css

Notes:

  1. The model generator creates a migration file.
  2. The scaffold generator creates actions, views, a layout and a stylesheet.

Categories: rubyonrails