Stubs for AJAX posts
This commit is contained in:
parent
27fc84552d
commit
4f0fe7d428
|
@ -0,0 +1,35 @@
|
|||
class MainController < ApplicationController
|
||||
def index
|
||||
@zoom = 15
|
||||
# Default coordinates: Boston center
|
||||
@lat, @lng = 42.358431, -71.059773
|
||||
@hydrants = []
|
||||
address, city_state = params[:address], params[:city_state]
|
||||
if address && city_state
|
||||
@zoom = 18
|
||||
@lat, @lng = Address.find_lat_lng("#{address}, #{city_state}")
|
||||
@hydrants = Hydrant.find_closest(@lat, @lng)
|
||||
end
|
||||
end
|
||||
|
||||
def sign_up
|
||||
@data = {"email" => params[:email], "name" => params[:name]}
|
||||
respond_to do |format|
|
||||
format.json{render :json => @data}
|
||||
end
|
||||
end
|
||||
|
||||
def sign_in
|
||||
@data = {"email" => params[:email]}
|
||||
respond_to do |format|
|
||||
format.json{render :json => @data}
|
||||
end
|
||||
end
|
||||
|
||||
def forgot_password
|
||||
@data = {"email" => params[:email]}
|
||||
respond_to do |format|
|
||||
format.json{render :json => @data}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
class WelcomeController < ApplicationController
|
||||
def index
|
||||
@zoom = 15
|
||||
# Default coordinates: Boston center
|
||||
@lat, @lng = 42.358431, -71.059773
|
||||
@hydrants = []
|
||||
address, city_state = params[:address], params[:city_state]
|
||||
if address && city_state
|
||||
@zoom = 18
|
||||
@lat, @lng = Address.find_lat_lng("#{address}, #{city_state}")
|
||||
@hydrants = Hydrant.find_closest(@lat, @lng)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -78,6 +78,12 @@
|
|||
$('.choose_password_label').removeClass('error', 500);
|
||||
$('.choose_password').removeClass('error', 500);
|
||||
}
|
||||
if(errors.length > 0) {
|
||||
errors[0].focus();
|
||||
} else {
|
||||
$.post('/sign_up.json', $(this).serialize(), function(data) {
|
||||
});
|
||||
}
|
||||
} else if($(this).data('state') === 'existing') {
|
||||
if($('.password').val() === '') {
|
||||
errors.push($('.password'));
|
||||
|
@ -87,11 +93,19 @@
|
|||
$('.password_label').removeClass('error', 500);
|
||||
$('.password').removeClass('error', 500);
|
||||
}
|
||||
if(errors.length > 0) {
|
||||
errors[0].focus();
|
||||
} else {
|
||||
$.post('/sign_in.json', $(this).serialize(), function(data) {
|
||||
});
|
||||
}
|
||||
} else if($(this).data('state') === 'forgot_password') {
|
||||
}
|
||||
if(errors.length > 0) {
|
||||
errors[0].focus();
|
||||
} else {
|
||||
if(errors.length > 0) {
|
||||
errors[0].focus();
|
||||
} else {
|
||||
$.post('/forgot_password.json', $(this).serialize(), function(data) {
|
||||
});
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
AdoptAHydrant::Application.routes.draw do
|
||||
get "javascripts/:action" => "javascripts#action"
|
||||
root :to => "welcome#index"
|
||||
get "/javascripts/:action" => "javascripts#action"
|
||||
post "/sign_up.:format" => "main#sign_up"
|
||||
post "/sign_in.:format" => "main#sign_in"
|
||||
post "/forgot_password.:format" => "main#forgot_password"
|
||||
root :to => "main#index"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue