-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ryankopf
committed
Jan 21, 2023
1 parent
ffcc42e
commit 3a84bd9
Showing
6 changed files
with
62 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module GeokitRails | ||
VERSION = "2.4.0.pre" | ||
VERSION = "2.5.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
class LocationAwareController < ApplicationController #:nodoc: all | ||
before_action :set_ip, only: [:index,:cookietest,:sessiontest] | ||
before_action :set_ip_bad, only: [:failtest] | ||
before_action :setup, only: [:cookietest,:sessiontest] | ||
geocode_ip_address | ||
|
||
def index | ||
render :nothing => true | ||
render plain: '' | ||
end | ||
|
||
def cookietest | ||
cookies[:geo_location] = @success.to_json | ||
render plain: '' | ||
end | ||
|
||
def sessiontest | ||
session[:geo_location] = @success.to_json | ||
render plain: '' | ||
end | ||
|
||
def failtest | ||
render plain: '' | ||
end | ||
|
||
def rescue_action(e) raise e end; | ||
private | ||
def set_ip | ||
request.remote_ip = "good ip" | ||
end | ||
def set_ip_bad | ||
request.remote_ip = "bad ip" | ||
end | ||
def setup | ||
@success = Geokit::GeoLoc.new | ||
@success.provider = "hostip" | ||
@success.lat = 41.7696 | ||
@success.lng = -88.4588 | ||
@success.city = "Sugar Grove" | ||
@success.state = "IL" | ||
@success.country_code = "US" | ||
@success.success = true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
Rails.application.routes.draw do | ||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html | ||
|
||
# Defines the root path route ("/") | ||
# root "articles#index" | ||
# get "/", controller: :LocationAware, action: :index | ||
match ':controller(/:action(/:id(.:format)))', via: [:get, :post] | ||
get "/", to: "location_aware#index" | ||
get "/cookietest", to: "location_aware#cookietest" | ||
get "/sessiontest", to: "location_aware#sessiontest" | ||
get "/failtest", to: "location_aware#failtest" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters