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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:15:44+00:00 2026-05-22T14:15:44+00:00

So in my view I’m using a calendar to select a day and drop

  • 0

So in my view I’m using a calendar to select a day and drop downs to select time. Therefore I’m using a before_validation method to put it together:

proposed_time.rb

before_validation :construct_starting_at

def construct_starting_at
  d = Time.parse(date)
  puts "************** construct_starting_at BEGIN *****************"
  puts "DATE: #{d}"
  puts "Time: #{time}"
  puts "Timezone: #{timezone}"
  puts "construct_starting_at :: #{d.year}-#{d.month}-#{d.day} #{time.hour}:#{time.min}:00 #{timezone}"
  if date.present? && time.present? && timezone.present?
    starting_at = Time.zone.parse("#{d.year}-#{d.month}-#{d.day} #{time.hour}:#{time.min}:00 #{timezone}")
  end
  puts "starting_at: #{starting_at}"
  puts "************** construct_starting_at END *****************"
end 

And it works just fine when I’m creating an object, but not when I’m updating it.

log

************** construct_starting_at BEGIN *****************
DATE: Fri Jun 03 00:00:00 -0500 2011
Time: Thu May 19 23:00:00 UTC 2011
Timezone: (GMT-05:00) Eastern Time (US & Canada)
construct_starting_at :: 2011-6-3 23:0:00 (GMT-05:00) Eastern Time (US & Canada)
starting_at: 2011-06-04 00:00:00 -0400
************** construct_starting_at END *****************

But when I use it for an update it looses it completely and reverts to what it was. This makes me feel like it isn’t actually being saved. So to help explain context on this next one, I have a ProposedTime object and it is a child of Consultation (each consultation has 3 proposed times) which also has accepts_nested_attributes_for :proposed_times:

consultation.rb

def proposed_times_attributes=(attributes)
  puts "$$$$$$$$$$$$$$ proposed_times_attributes $$$$$$$$$$$$$$$$"
  attributes.each do |key,value|
    value[:timezone] = timezone
    if value[:id]
      puts "Updating #{value[:id]}"
      p = ProposedTime.find(value[:id])
      value.delete(:id)
      unless p.update_attributes(value)
        puts "@@@@@@@@@@@@@@@@@ ERROR @@@@@@@@@@@@@@@"
        error.add(:proposed_times, "something is wrong")
      end
      puts "-- starting_at:  #{p.starting_at}"
    else
      puts "Creating a new proposed time"
      proposed_times << ProposedTime.new(value)
    end
  end
  puts "$$$$$$$$$$$$$$ proposed_times_attributes $$$$$$$$$$$$$$$$"
end

log

...
Updating 18
************** construct_starting_at BEGIN *****************
DATE: Fri Jun 03 00:00:00 -0500 2011
Time: Thu May 19 23:00:00 UTC 2011
Timezone: (GMT-05:00) Eastern Time (US & Canada)
construct_starting_at :: 2011-6-3 23:0:00 (GMT-05:00) Eastern Time (US & Canada)
starting_at: 2011-06-04 00:00:00 -0400
************** construct_starting_at END *****************
-- starting_at:  2011-06-01 06:00:00 -0400

I thought it might have been throwing an error on the update_attributes, but it doesn’t seem like it is. Any ideas?

  • 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-22T14:15:45+00:00Added an answer on May 22, 2026 at 2:15 pm

    I haven’t groked this fully, but I’m just going for the simple things – I think you want starting_at to not be a local variable, but actually set your object’s starting_at attribute:

    self.starting_at = Time.zone.parse("#{d.year}-#{d.month}-#{d.day} #{time.hour}:#{time.min}:00 #{timezone}")
    

    The key bit being the self., to actually make sure the attribute is set, not some local variable of the same name that only exists within that method.

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

Sidebar

Related Questions

View: <% form_tag(:action => 'create', :multipart => true) do %> Select CSV File: <%=
View Here: http://174.132.101.73/~ree/header/ I have a drop down box. I am trying to get
{{view Ember.Select contentBinding=ResAdmin.adminController.priceCategories valueBinding=selectedRestaurant.PriceCategoryID optionLabelPath=content.name optionValuePath=content.id}} how can i add the default value like
`//View <tr><td>Experience level</td><td><div class=editor-field> <%: Html.DropDownListFor(model => model.ExperienceLevelID, (SelectList)ViewData[Experience], --select--)%> <%: Html.ValidationMessageFor(model => model.ExperienceLevelID)
view-source:http://127.0.0.1:5000/admin/post/edit/2 : <form action=/admin/post/update_post/2 method=post> view-source:http://xxx.com/admin/post/edit/2 <form action=/admin/post/edit/2/admin/post/update_post/2 method=post> something was diffent between server
My 'VIEW' is ordered. But when I use a select to show its result,
The View() method can load Partial Views. Is the difference between View() and PartialView()
View model is loading data asynchronously using background worker thread in model. All properties
create view Com as select C.id, IF(A.agree = null) THEN 0 else A.agree end
CREATE VIEW View1 AS SELECT Col1, Col2, dbo.fn1(col2) as Col3 FROM TestTable /* --Instead

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.