Pretty simple, I need to disable time zone conversion for specific columns. I will handle any TZ conversion manually, but I need Rails 3 to forego conversion in both writing and reading, and any AREL functions. But, I don''t want to disable the conversion for non-specified attributes. I know how to disable it for reading: self.skip_time_zone_conversion_for_attributes = [:test_timestamp] But this only works for reading. When writing the attribute, it still converts to UTC (yes, I tested this in 3.2.8). How? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/9JjYyc88WlsJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Is it possible to offset the "damage" from rails by writing your own attr reader/writer? Sent from my phone On 2012-10-18, at 4:39 PM, Karl Smith <threadhead@gmail.com> wrote:> Pretty simple, I need to disable time zone conversion for specific columns. I will handle any TZ conversion manually, but I need Rails 3 to forego conversion in both writing and reading, and any AREL functions. But, I don''t want to disable the conversion for non-specified attributes. > > I know how to disable it for reading: > >> self.skip_time_zone_conversion_for_attributes = [:test_timestamp] > > But this only works for reading. When writing the attribute, it still converts to UTC (yes, I tested this in 3.2.8). > > How? > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/9JjYyc88WlsJ. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Tried that. Does not work. Rails still does the time zone conversion when
persisting to the database.
Example:
class Widget < ActiveRecord::Base
def closed_at=(time)
write_attribute(:closed_at, time)
end
end
in console:> Time.zone = "Arizona"
=> "Arizona"> Time.now.in_time_zone("Hawaii")
=> Fri, 19 Oct 2012 06:43:39 HST -10:00 > a = Widget.create({closed_at: Time.now.in_time_zone("Hawaii")})
> a.inspect
=> "#<Widget id: 1, closed_at: "2012-10-19
16:43:48">"
Rails is still doing the time zone conversion.
Maybe there is a different way to override the attribute writer?
On Thursday, October 18, 2012 5:49:42 PM UTC-7, Godfrey Chan
wrote:>
> Is it possible to offset the "damage" from rails by writing your
own attr
> reader/writer?
>
> Sent from my phone
>
> On 2012-10-18, at 4:39 PM, Karl Smith <threa...@gmail.com
<javascript:>>
> wrote:
>
> Pretty simple, I need to disable time zone conversion for specific
> columns. I will handle any TZ conversion manually, but I need Rails 3 to
> forego conversion in both writing and reading, and any AREL functions. But,
> I don''t want to disable the conversion for non-specified
attributes.
>
> I know how to disable it for reading:
>
> self.skip_time_zone_conversion_for_attributes = [:test_timestamp]
>
>
> But this only works for reading. When writing the attribute, it still
> converts to UTC (yes, I tested this in 3.2.8).
>
> How?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-core/-/9JjYyc88WlsJ.
> To post to this group, send email to
rubyonra...@googlegroups.com<javascript:>
> .
> To unsubscribe from this group, send email to
> rubyonrails-co...@googlegroups.com <javascript:>.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-core/-/IlHGQA1ljtEJ.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.