Hello,
Using rails 2.3.9 and ruby 1.8.7
I am trying add time zone in the site according to user's time zone
(selected by the user from the drop down of time zones)Code is done as
follows, but time zone is not getting saved in the database.
IN Application Controller
before_filter :set_time_zone
def set_time_zone
Time.zone = current_user.time_zone if current_user
end

IN View form(haml)
f.time_zone_select :time_zone, ActiveSupport::TimeZone.all.sort

IN Environment.rb
config.time_zone = 'UTC'

IN User table added time_zone as string column

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Nov 11, 2011 at 11:41 am

    On 11 November 2011 11:30, Annapoorna R wrote:
    Hello,
    Using rails 2.3.9 and ruby 1.8.7
    I am trying add time zone in the site according to user's time zone
    (selected by the user from the drop down of time zones)Code is done as
    follows, but time zone is not getting saved in the database.
    IN Application Controller
    before_filter :set_time_zone
    def set_time_zone
    Time.zone = current_user.time_zone if current_user
    end

    IN View form(haml)
    f.time_zone_select  :time_zone, ActiveSupport::TimeZone.all.sort

    IN Environment.rb
    config.time_zone = 'UTC'

    IN User table added time_zone as string column
    To summarise, you have a time_zone string column in the database, but
    you say that it is not getting saved to the database. First have a
    look in the application log to see whether the zone is getting passed
    when you click on the submit link for the form. If that looks ok then
    use ruby-debug to break into the create or update method to see
    whether params is setup ok and whether the User. See the Rails Guide
    on debugging if you do not know how to do this.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 11, '11 at 11:30a
activeNov 11, '11 at 11:41a
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Colin Law: 1 post Annapoorna R: 1 post

People

Translate

site design / logo © 2021 Grokbase