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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:24:15+00:00 2026-05-26T08:24:15+00:00

I am doing a before_validation as follows: event.rb attr_accessor :start_date attr_accessible :start_time #recorded in

  • 0

I am doing a before_validation as follows:

event.rb

attr_accessor :start_date
attr_accessible :start_time #recorded in database as a datetime

before_validation :build_start_time

...

def build_start_time
  begin
    self.start_time = DateTime.parse(start_date)
  rescue
      errors.add(:start_date, "invalid date")
      return false
  end
end

and the controller looks like:

def create
  @event = events.build(params[:event])
  if @event.save
    # some other method calls
    redirect_to @event
  else
    redirect_to :root
  end
end

start_date is being set by a <%= f.text_field :start_date %> call in a form view, and when I check the params it is being passed to the ‘Create’ method of the model controller correctly, but in the build_start_time method it is nil, so self.start_time is not being set. Can you explain why it would be nil and what the solution would be? I also tried referring to it as self.start_date but that didn’t make a difference.

Thanks

  • 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-26T08:24:16+00:00Added an answer on May 26, 2026 at 8:24 am

    Have you tried making start_date also accessible?

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

Sidebar

Related Questions

I have very little experience with ASP.NET and I am doing some self-training before
I'm having a problem with validation in my RoR Model: def save self.accessed =
Im working with dataSets validation in my project. I'm doing validation when DataTable_ColumnChanged event
I want to validate a condition before doing the next step, but only raise
Is there a way to run the changed files through a filter before doing
That might be a naive git question but here it is: Before doing a
Before I have tried about doing one attachment (upload) for each record of my
...before everything, I'm doing this out of curiosity only. Nothing real-world application here, but
What is this code doing? Specifically the default(XX) part. I've never seen it before.
Doing an ajax get request works as expected using the following code: $.ajax({ type:

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.