Deviseユーザーの登録コントローラーを上書きして、ユーザーが都市を変更したかどうかを確認し、変更した場合は、セッションでGeokitオブジェクトを再度ロードします。
session[:geo_location] = User.geocode(resource.city) if resource.city_changed?
問題はそれをしていないということです。以下のコードでは何も返されません。if resource.city_changed?
削除すると、リソースが変更されているかどうかに関係なく、すべての場合に削除されます。
User::RegistrationsController < Devise::RegistrationsController
def update
self.resource = resource_class.to_adapter.get!(send(:"current_# {resource_name}").to_key)
if resource.update_with_password(params[resource_name])
session[:geo_location] = User.geocode(resource.city) if resource.city_changed?
set_flash_message :notice, :updated if is_navigational_format?
sign_in resource_name, resource, :bypass => true
respond_with resource, :location => after_update_path_for(resource)
else
clean_up_passwords(resource)
respond_with_navigational(resource){ render_with_scope :edit }
end
end
end