Quantcast
Channel: Mike Kruckenberg
Viewing all articles
Browse latest Browse all 16

RailsConf 2011: Rails for Zombies

$
0
0

I'm at RailsConf 2011 this morning, listening to a bunch of guys from envy labs doing an introductory course to Ruby on Rails. I've dug in deep on Ruby on Rails for a month now, this might be a bit too introductory for where I'm at but want to make sure I've got the basics.

Things I learned that I didn't know about Rails:


  • When you do a lookup of an object you can call Object.save at any point and it will save the object back to the database with any changed values. I've always used Object.update_attributes

  • Object.attributes method accepts a hash to update multiple values.

  • You can reference a Rails value with object[:field] or object.field. The latter is more common in the Rails community.

  • Rails typical thinking is to put validation in the model, not in the database.

  • Rails 3 has different syntax for validation, you set the validation in the ActiveRecord::Base subclass with.

  • When saving to the database that has the relationships set up in the model, you can pass in the object (not just the object_id) to the new/create method and it will find the id to store in the database.

  • .erb files stand for Embedded Ruby

  • Rails first checks the public folder for a match to the URL and then goes to the routes file.

  • Show "no results found" by checking Object.all.empty?



Viewing all articles
Browse latest Browse all 16

Latest Images

Trending Articles





Latest Images