Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 754047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:58:03+00:00 2026-05-14T14:58:03+00:00

I have several models: Email Letter Call All three belong to a model Campaign.

  • 0

I have several models:

  • Email
  • 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:58:03+00:00Added an answer on May 14, 2026 at 2:58 pm

    You’re actually asking the wrong question.. Controllers aren’t linked to any model fundamentally, they really display whatever you want. You can have a FooController that displays all the Bars and a DogController that gives info about cats..

    To solve your problem:

    1. You’re not ‘sharing’ anything with
      your view for it to display.
    2. You’re also putting the logic in the
      wrong place, and you’re not actually
      fetching the campaigns from the
      database..

    In your controller you need to fetch the data from the DB:

    def index
      @campaigns = Campaign.all #share the list of campaigns with the view
    end
    

    In your view you display the campaign info..

    <% for campaign in @campaigns %>
    <!-- display info about the campaign -->
    
      <% for contacts in campaign.contacts %>
    <!-- contact level info and so on.. -->
    
      <% end %>
    <% end %>
    

    There’s much more to it, but hopefully this gets you pointed in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several models that need to call a method that takes a particular
I have several models: ContactEmail, ContactLetter, ContactCall My controller doesn't know what is being
I have several models with a date attribute and for each model I'd like
I have a model with several embedded models. I need to query for a
I have several doctrine models that have relationships to other models. Let's call those
I have several models that belong_to :status . Statuses are: Active Hidden Banned I
I have several Mongoid models that I'm running mapreduce on, and I'd like to
If you have several view models on one page, how do you ensure that
I have several 'lookup' fields in my models where I don't want nulls, but
I have several small classes that are in a single file in /app/models, similar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.