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

  • Home
  • SEARCH
  • 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 8865735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:35:28+00:00 2026-06-14T16:35:28+00:00

I have two methods which are used to determine whether to apply a class

  • 0

I have two methods which are used to determine whether to apply a class to the page to show that something is overdue and needs attention.

I’m getting an error when a brand new user registers:

undefined method `last_contact_done_date=' for #<User:0x6183708>

The line that it’s referencing the error to is this:

2:   <div class="span3 <%= "overdue" if (signed_in? && contact_overdue?(current_user.id)) %>">

The contact_overdue? method is this (in a home page helper)

def contact_overdue?(user_id)
  @user = User.find_by_id(user_id)
  return true if (Date.today - (@user.last_contact_done_date ||= Date.tomorrow)) > 6
end

and the last_contact_done_date method is this in the User model

  def last_contact_done_date
      self.contacts.order('date_done DESC').first.try(:date_done)
  end

I thought that if I was using the ||= operator in the contact_overdue? method, then I would return -1 if the last_contact_done_date is nil. But it appears that’s not working. What operator should I be using in last_contact_done_date or how should I change the contact_overdue? method so that if there are no contacts, then false is returned from the contact_overdue? method?

  • 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-06-14T16:35:30+00:00Added an answer on June 14, 2026 at 4:35 pm

    To return the default value of -1 when there is no last contact done date, use

    @user.last_contact_done_date || -1
    

    (it is unreasonable to expect Date.tomorrow to return -1 😉 )

    ||= is an assignment operator; a ||= b is equivalent to a = a || b; and if a is an attribute (i.e. is prefixed with a dot and an instance, c.a), assignment to it will call the method a=. Thus, your code necessitates that you have a method named last_contact_done_date= to handle the assignment, which you don’t.

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

Sidebar

Related Questions

I have a List object in my class and two methods which are used
I have two methods, one called straight after another, which both throw the exact
I have two helper methods inside a custom View which are called by their
I have found only two methods (SaveFile, LoadFile) which save in a file. How
I have two files called file_utils.h and file_utils.cpp which contain some methods and variables
I have two methods, the first needs a Map<ItemA, ItemB> the second a Map<ItemA
I have two methods, one that I use to convert an image to a
Let's say I have two methods, one of which is basically a wrapper for
I have two static methods that I want to use for error handling. One
I have a method which compares two objects and returns a list of all

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.