Web Development  >>  Ruby On Rails

Dynamic find_by Methods

Language : English Quality : High Has Audio : true Source : Other Media : n/a
Shorten simple finds considerably and improve readability by using the dynamic find_all_by and find_by methods

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

Resources referenced in this screencast
  • Ruby on Rails

  • Created : 2007-03-07   Duration : 01:28

    Articles Realted to this Topic

    [SUGGEST  A  ARTICLE]
    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
    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