Reputation: 2044
I have Event model which contains following fields
string "name"
date "start_at"
date "end_at"
datetime "created_at"
datetime "updated_at"
string "trainer"
string "venue"
string "description"
boolean "holy"
integer "nxt"
And I have also save holidays in the event that contains trainer as '0' so I need to find all the holidays on event table. Can expert give me some idea to implement this ?
Upvotes: 3
Views: 159
Reputation: 15965
Rails has dynamic finders. I'm not sure if I understand your question correctly, but this code should find all Events that have trainer = 0. To find one holiday use:
Event.find_by_trainer("0")
To find all, use:
Event.find_all_by_trainer("0")
Upvotes: 3
Reputation: 21180
I guess that you are looking for something like:
@events = Event.where(:trainer => "0")
Upvotes: 1