Web Development  >>  Ruby On Rails

Railscasts Week 1

Language : English Quality : High Has Audio : true Source : showmedo Media : Flash
Let Ryan Bates take you through a growing series of great Rails tips.

Tags: Ruby On Rails, Ruby, Screencast, Showmedo, Web Development,     [SUGGEST  A  TAG]

Resources referenced in this screencast
  • Ruby on Rails
  • Caching with Instance Variables

    Learn a quick way to improve performance. Just store the end result of an expensive command in an instance variable!

    Dynamic find_by Methods

    Shorten simple finds considerably and improve readability by using the dynamic find_all_by and find_by methods.

    Find Through Association

    No need to pass foreign keys in find conditions, just do the find through a has_many association.

    Articles Realted to this Topic

    How dynamic finders work
    As part of its magic, ActiveRecord gives you some convenience methods to find records by their attribute values. These methods are called dynamic finders. There are two forms, find_by_whatever, and find_or_create_by_whatever to create the record if you can't find it. (In edge Rails there is also find_or_initialize_by_whatever which instantiates the model but doesn't save it.) You can use one attribute or many
    Content-only caching for Rails
    So you’ve got a Rails app which is mostly static content, but it’s got some dynamic, user-specific stuff mixed in with the layout. You’d love to cache the static data, since it doesn’t change often, but that would leave you updating the dynamic content via AJAX or something, and as cool as AJAX is, it’s for crap when the Javascript is turned off
    Basic Rails association cardinality
    ActiveRecord associations can be used to describe relations with one-to-one, one-to-many and many-to-many cardinality. Each model uses an association to describe its role in the relation. In each case, the belongs_to association is used in the model that has the foreign key
    19 Rails Tricks Most Rails Coders Don't Know
    When looking at my own Rails code and that of the community as a whole, I often see places where certain Rails techniques could have been used, but weren't. As much for my own memory as yours, I thought I'd list down some Rails tricks and tips that can make your application or code more efficient