Find_by_tag

What exactly is find_by_tag for? The rails documentation doesn’t really
give a description of what it does. I tried doing a search for
find_by_tag (and find_all_by_tag), but nothing turned up.

Have a look at dynamic finders: if you have an attribute foo then you’ll
magically get find_by_foo and find_all_by_foo.
find_by_foo ‘bob’ just does find :first, :conditions => [‘foo = ?’,
‘bob’]
find_all_by_foo does what you would expect, both are rather more
readable than the alternative.
You can also chain 'em up: find_by_foo_and_bar

Fred

This may be a method from the acts_as_taggable plugin…

http://wiki.rubyonrails.org/rails/pages/Acts+As+Taggable+Plugin

–Jeremy

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs