April 21st, 2008, 02:14 PM
Model find_by_column_name only returns 1 result
If i go
stories = Story.find_by_genre_id(8)
The model retrieves the first record with genre_id = 8...why doesnt it return all the stories with genre_id = 8?
class Genre < ActiveRecord::Base
class Story < ActiveRecord::Base
April 27th, 2008, 04:07 AM
Yup, that's how it is designed. If you know you have more than one record, use find_all_by_genre_id() instead of find_by_genre_id()
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
im just starting out with RoR, but what about
stories = Genre.find_by_id(8).stories
That almost works, just use find() instead of find_by_id().
Originally Posted by intrktevo
Actually, that works too! Sorry.
Last edited by destin; May 29th, 2008 at 08:36 AM.