#259 ✓resolved
Ashley Moran

Time fields not working

Reported by Ashley Moran | September 8th, 2008 @ 07:27 PM

Hobo seems to have an issue with :time fields.

To recreate the issue:

% rails time_test

Add HoboFields to config/environment.rb:

config.gem 'hobosupport', :version => '>= 0.8.1'
config.gem 'hobofields', :version => '~> 0.8.1'

% script/generate hobo_model TestModel test_time:time

Migrate from within the Hobo migration command:
% script/generate hobo_migration

% script/console

TestModel.create!(:test_time => "12:00:00")

Fails with:

ArgumentError: wrong number of arguments (1 for 0)
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/attribute_methods.rb:211:in initialize'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/attribute_methods.rb:211:innew'
...

To fix:

Change lib/hobo_fields.rb PLAIN_TYPES to read:

  PLAIN_TYPES = {
    :boolean       => Hobo::Boolean,
    :date          => Date,
    :datetime      => (defined?(ActiveSupport::TimeWithZone) ? ActiveSupport::TimeWithZone : Time),
    # ADDED:
    :time          => (defined?(ActiveSupport::TimeWithZone) ? ActiveSupport::TimeWithZone : Time),
    :integer       => Fixnum,
    :big_integer   => BigDecimal,
    :decimal       => BigDecimal,
    :float         => Float,
    :string        => String
  }

Don't actually know why that fixes it, hopefully you have more insight!!!

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages