Skip to content

Instantly share code, notes, and snippets.

@arturo-c
Created October 12, 2013 12:59
Show Gist options
  • Save arturo-c/6949779 to your computer and use it in GitHub Desktop.
Save arturo-c/6949779 to your computer and use it in GitHub Desktop.
diff --git Gemfile Gemfile
index cecf9d3..51dc2f2 100644
--- Gemfile
+++ Gemfile
@@ -12,6 +12,7 @@ gem 'mongoid'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'twitter'
+gem 'geocoder'
group :development do
gem 'better_errors'
gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
diff --git Gemfile.lock Gemfile.lock
index f2c4394..2ac1d0e 100644
--- Gemfile.lock
+++ Gemfile.lock
@@ -81,6 +81,7 @@ GEM
figaro (0.7.0)
bundler (~> 1.0)
rails (>= 3, < 5)
+ geocoder (1.1.8)
gherkin (2.12.1)
multi_json (~> 1.3)
hashie (2.0.5)
@@ -217,6 +218,7 @@ DEPENDENCIES
email_spec
factory_girl_rails
figaro
+ geocoder
jquery-rails
launchy
mongoid
diff --git app/controllers/games_controller.rb app/controllers/games_controller.rb
new file mode 100644
index 0000000..5da8a19
--- /dev/null
+++ app/controllers/games_controller.rb
@@ -0,0 +1,14 @@
+class GamesController < ApplicationController
+ def index
+ if session[:client]
+ client = session[:client]
+ timeline = client.home_timeline
+ test = Geocoder.coordinates('75243')
+ search = client.search("pick-up game", :count => 100, :geocode => test[0].to_s + ',' + test[1].to_s + ',50mi')
+ tweet = client.status(388432224955031552)
+ user = client.user_timeline(785708023)
+
+ client
+ end
+ end
+end
\ No newline at end of file
diff --git app/controllers/sessions_controller.rb app/controllers/sessions_controller.rb
index 0b767bd..0e16cf6 100644
--- app/controllers/sessions_controller.rb
+++ app/controllers/sessions_controller.rb
@@ -9,13 +9,12 @@ class SessionsController < ApplicationController
auth = request.env["omniauth.auth"]
user = User.where(:provider => auth['provider'],
:uid => auth['uid'].to_s).first || User.create_with_omniauth(auth)
- client = Twitter::Client.new(
- :oauth_token => auth['credentials']['token'],
- :oauth_consumer => auth['credentials']['secret']
- )
- timeline = Twitter.home_timeline
reset_session
session[:user_id] = user.id
+ session[:client] = Twitter::Client.new(
+ :oauth_token => auth['credentials']['token'],
+ :oauth_token_secret => auth['credentials']['secret']
+ )
if user.email.blank?
redirect_to edit_user_path(user), :alert => "Please enter your email address."
else
diff --git app/views/games/index.html.erb app/views/games/index.html.erb
new file mode 100644
index 0000000..30ee8a2
--- /dev/null
+++ app/views/games/index.html.erb
@@ -0,0 +1,6 @@
+<h3>Home</h3>
+<% unless @games.nil? %>
+<% @games.each do |game| %>
+ <p>Game: <%=link_to game.name, game %></p>
+<% end %>
+<% end %>
diff --git config/routes.rb config/routes.rb
index cde2ce1..28228ad 100644
--- config/routes.rb
+++ config/routes.rb
@@ -1,6 +1,7 @@
Pugwarriors::Application.routes.draw do
- root :to => "home#index"
+ root :to => "games#index"
resources :users, :only => [:index, :show, :edit, :update ]
+ resources :games
match '/auth/:provider/callback' => 'sessions#create'
match '/signin' => 'sessions#new', :as => :signin
match '/signout' => 'sessions#destroy', :as => :signout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment