Rails: Some New User Advice

It’s been about a month into learning Ruby and Rails now I’ve stumbled across a number of things I think might be good advice for other beginners. In the intrists of altruism, here they are:

Create a Hello World app first, without worrying about doing anything with the database
After the Hello World is done and before [...]

Rails: Creating Database Migrations

Part of the sweet tool suite in Rails is ActiveRecord’s Migration, a database-agnostic mechanism for defining the application’s database structure as well as any changes that need to be made to the database over the life of the project.
The Rails wiki entry for Using Migrations.
The supported datatypes for database columns (note that these don’t map [...]

Rails: Getting Routed

Jamis Buck, one of the core developers of Ruby on Rails, writes an indispensable Rails blog with the unweildy name of the { buckblogs :here }. I’ve been reading it daily, learning something new about Rails each day. Today’s post, Named, explicit routes is all about routing paths in Rails, something up until now I [...]

Rails: Updating the core

Ruby on Rails 1.2 was recently released (up to 1.2.1 as most stable now) and it turns out that updating to 1.2.1 under OS X is as simple as:

$ sudo gem update rails

Rails: Cancel Buttons and Forms

The Rails framework provides a great wealth of helper functions for creating forms via the FormHelper, FormTagHelper and FormOptionsHelper classes but one item conspicuously missing for some reason is a Cancel button.
Creating one is pretty straighforward, however. Lets say there's a form in place for creating new User groups:
PLAIN TEXT
RUBY:

<%= form_tag :action => 'create' %>

<%= [...]

Rails: Knowing the current Action in a View

At some point you, like me, may want to do something in a Rails view that is dependent upon the current action. But how to know what the currect action is (without doing some ugly URL parsing)?
The Highlight link for current action over on Code Snippets has the solution.
Add the following to your application.rb controller:
PLAIN [...]

Mach Speed Ruby Class

I've created a Ruby class for converting from Km/h to Mach speed and vice versa: Ruby Class: Mach Speed. Probably not too useful to you unless you're working in aviation or aeronautics (Curious to know what your Mach walking speed is, assuming 4 Km/h on a nice day? Mach 0.0032).

Temperature Conversion Ruby Class

For fun I've created a Ruby a temperature conversion class. Converts between Celcius, Fahrenheit, Kelvin and Rankine (who uses Réaumur anymore?): Ruby Class: Temperature Conversion.

« go back