Open nomasprime opened 10 years ago
Please can you share the code you're using which generates those errors.
Hi @robertgauld, I've created a gist and updated the description.
Can you humor me and make the following chnage, it shouldn't make a difference but it just might.
# app/models/event.rb
class Event < ActiveRecord::Base
date_time_attribute :start
date_time_attribute :end
end
@robertgauld we can easily start from specs here :)
@robertgauld negatory, same error.
+1 getting same error here. Also using separate date and time selects.
fyi: http://arjanvandergaag.nl/blog/rails_attributes_magic.html gives a good run down on whats going on, rails is just assigning these virtual attributes as strings.
@habitullence There's a way around this:
in your case:
# app/models/event.rb
class Event < ActiveRecord::Base
date_time_attribute :start, :end
self.columns_hash['start_time'] = OpenStruct.new(type: :time, klass: Time)
self.columns_hash['start_date'] = OpenStruct.new(type: :date, klass: Date)
self.columns_hash['end_time'] = OpenStruct.new(type: :time, klass: Time)
self.columns_hash['end_date'] = OpenStruct.new(type: :date, klass: Date)
end
You can alternatively swap out the OpenStruct
for something like : ActiveRecord::ConnectionAdapters::Column.new("expiration_date", nil, "date")
Be sure to not have ignore_date
as part of your options on your time select, or you will run into the same issue.
Newish to Rails, followed the docs but getting the following error:
Code - https://gist.github.com/habitullence/533730edef77f4e1a48a