How do I create a controller and action without a model?
Posted
by Angela
on Stack Overflow
See other posts from Stack Overflow
or by Angela
Published on 2010-04-27T18:43:29Z
Indexed on
2010/04/27
20:23 UTC
Read the original article
Hit count: 359
I have several models:
- Letter
- Call
All three belong to a model Campaign. And a Campaign has_many Contacts
I envision being able to see a schedule for Today by going to domain/schedule/today
What I'd like it to do would be to show all the Events (Email, Letter, Call) that have to happen today for each campaign.
I tried the following, but have some challenges in putting it into a controller versus into a View. There are many emails in campaign.
Email.days is the number of days from the contact.start_date that an email should be sent to the Contact.
ScheduleController <
def index
campaigns.each do |campaign| #goes through each campaign
for contacts in campaign.contacts
Email.find(:all).reject { |email| email.contact.start_date + email.days <= Date.now }
end
end
end
© Stack Overflow or respective owner