]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_controller.rb
Ajaxify the country selection on the terms page
[rails.git] / app / controllers / user_controller.rb
index 94a3e11426a0fb215960800775d89ab66ea1b734..27d124daeae3423e7bc22a4e1d50235f9b7a00d8 100644 (file)
@@ -22,7 +22,14 @@ class UserController < ApplicationController
     @title = t 'user.new.title'
     @user = User.new(params[:user])
 
-    if @user.invalid?
+    @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || APP_CONFIG['default_legale']
+    @text = OSM.legal_text_for_country(@legale)
+
+    if request.xhr?
+      render :update do |page|
+        page.replace_html "contributorTerms", :partial => "terms"
+      end
+    elsif @user.invalid?
       render :action => 'new'
     end
   end