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 7875959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:05:17+00:00 2026-06-03T03:05:17+00:00

I am sure I am just doing this wrong, can someone point me in

  • 0

I am sure I am just doing this wrong, can someone point me in the right direction?

I need to set the value of effective_date to a modified format date

effective_date is an attribute of Request

class Request < ActiveRecord::Base

  def format_date=(format_date)
    date_a = format_date.split("/")
    month, day, year = date_a
    effective_date = Date.parse("#{year}-#{month}-#{day}")
  end

  def format_date
    effective_date
  end
end

Request.create(format_date: "04/21/2012") is not setting the value to effect_date

Edit: I guess this doesn’t make sense, so I will try and explain it better:

I need to set the value of effective_date (a column in the database) from format_date (not a column in the database). I am using format_date method to convert the date from format_date and store it into effective_date. If this isn’t enough info, let me know. I am not sure what else to add.

  • 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-03T03:05:18+00:00Added an answer on June 3, 2026 at 3:05 am

    If effective_date is the column name in your database, the change is as simple as

    def format_date=(format_date)
      date_a = format_date.split("/")
      month, day, year = date_a
      self.effective_date = Date.parse("#{year}-#{month}-#{day}")
    end
    

    The only change was effective_date = to self.effective_date =. Without adding self there, there’s no way for the interpreter to know whether you want to set a local variable called effective_date or call the effective_date= method. It assumes the local variable.

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

Sidebar

Related Questions

I'm sure I'm just doing something stupid here, but I can't quite figure out
I'm not sure if I'm doing this the right way. I have table which
I am certain I am just doing this the wrong way, but I cant
I feel like I'm doing this wrong, or it's just a result of my
I am doing a md5 hash, and just want to make sure the result
I am sure I am just missing something. But I have googled this for
I'm sure I've just missed this in the manual, but how do you determine
I am sure it's just a little mistake, but i can't find it. When
I've been beating my head against this, and I'm sure I'm just missing something
Not sure if I've just missed something but this doesn't work: $(this).children('td.threadtitle a').html('thread title');

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.