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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:36:56+00:00 2026-05-18T05:36:56+00:00

I believe that datetime_select is black magic. What I’m really trying to figure out

  • 0

I believe that datetime_select is black magic. What I’m really trying to figure out is the whole 1i,2i,3i,4i… multiple parameters stuff. Specifically how is it handled in the back end (activerecord, something else?). What’s with the ‘i’ after the order-number? Is it a type-specifier? If so what are other types that are available? I’ve read the source of date_helper.rb and it’s quite opaque.

Here’s my motivation:

I’ve got a :datetime column in my model and I want to input in the view via two text_fields: one for date and one for time. They need to be validated, merged together, then stored into the datetime column. Ultimately I’ll be using a javascript calendar to input dates into the date field.

So has anybody done this? I tried using virtual attributes (incredibly undocumented besides the rudimentary railscast) and the issue was that when a new activerecord object is created and has nil attributes, the virtual attribute fails (undefined method strftime for nil class, which makes sense).

Anybody have any suggestions or best practices? 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-18T05:36:56+00:00Added an answer on May 18, 2026 at 5:36 am

    I had the same question. Here’s what I found…

    http://apidock.com/rails/ActiveRecord/Base/assign_multiparameter_attributes

    assign_multiparameter_attributes(pairs)
    private

    Instantiates objects for all attribute
    classes that needs more than one
    constructor parameter. This is done by
    calling new on the column type or
    aggregation type (through composed_of)
    object with these parameters. So
    having the pairs written_on(1) =
    “2004”, written_on(2) = “6”,
    written_on(3) = “24”, will instantiate
    written_on (a date type) with
    Date.new(“2004”, “6”, “24”). You can
    also specify a typecast character in
    the parentheses to have the parameters
    typecasted before they’re used in the
    constructor. Use i for Fixnum, f for
    Float, s for String, and a for Array.
    If all the values for a given
    attribute are empty, the attribute
    will be set to nil.

    So the numbers are for the parameters of the data type that the column is. The “i” is to convert it to an integer. Other types are supported like “f” for float, etc.

    You can see here in execute_callstack_for_multiparameter_attributes that it detects the target type and instantiates it passing the values.

    So, to try directly answering the posed question, I don’t think you can use it to override how a DateTime is created because it uses the constructor which doesn’t support the format you want to pass in. My work-around was to split the DateTime column out to one Date and one Time column. Then the UI could work the way I wanted.

    I wonder if it might be possible to create attribute accessors on the class that represent the date and time separately but keep a single DateTime column. Then the form could reference those separate accessors. That might be workable. Another option might be to use composed_of to customize the type further.

    Hope that helps someone else. 🙂

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

Sidebar

Related Questions

I've been raised to believe that if multiple threads can access a variable, then
I believe that Agile is nothing but another implementation of Spiral Model. I am
I believe that quantifying the productivity increase (extra working hours) is the most effective
I believe that IDictionary classes works better with sortable objects. I believe also that
I believe that I have successfully impersonated my own user account while running an
I'm lead to believe that I cannot count on the order of items added
Premise I believe that there is a way to objectively define "Good" and "Bad"
I've been led to believe that for single variable assignment in T-SQL, set is
Here I am faced with an issue that I believe(or at least hope) was
I am looking at improving a package that I believe not to be threadsafe

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.