I am using time_zone_select for the first time:
<%= time_zone_select('user', 'default_timezone') %>
I have an instance variable called user and that model has an attribute called 'default_timezone'.
The list displays and when I submit the form, I see it sends the data:
Parameters: {"user"=>{"auto_update_map"=>"1", "default_timezone"=>"London"}, "device"=>{"81"=>{"nickname"=>"BonzoHunter"}}, "Submit"=>"Save Changes", "action"=>"update_prefs", "controller"=>"user"}
But, the UPDATE sets default_timezone to NULL:
UPDATE user_accounts SET "default_timezone" = NULL, "auto_update_map" = 1 WHERE id = 27
Huh? The other attribute I set, 'auto_update_map', works like a charm and I can see that the parameter was sent.
Simple code:
@user.default_timezone = params[:user][:default_timezone] @user.auto_update_map = params[:user][:auto_update_map] @user.save
So, what I am doing wrong here?
Thanks, H