oauth rails error - undefined method `request_uri' for - ruby-on-rails

I was using Oauth in my project for quite a long time (and I am sure it was working before), but after some time it has broken for all providers at the same time and for all providers (facebook, vkontakte, twitter)
The error is
undefined method `request_uri' for #<URI::Generic https://graph.facebook.com/oauth/access_token>
I tried to downgrade to ruby 1.9.0 (from 2.1.0) - it is still the same
Full stack is
NoMethodError (undefined method `request_uri' for #<URI::Generic:0x00000101ee8f48>):
faraday (0.9.1) lib/faraday/adapter/net_http.rb:66:in `create_request'
faraday (0.9.1) lib/faraday/adapter/net_http.rb:82:in `perform_request'
faraday (0.9.1) lib/faraday/adapter/net_http.rb:40:in `block in call'
faraday (0.9.1) lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
faraday (0.9.1) lib/faraday/adapter/net_http.rb:32:in `call'
faraday (0.9.1) lib/faraday/request/url_encoded.rb:15:in `call'
faraday (0.9.1) lib/faraday/rack_builder.rb:139:in `build_response'
faraday (0.9.1) lib/faraday/connection.rb:377:in `run_request'
oauth2 (1.0.0) lib/oauth2/client.rb:93:in `request'
oauth2 (1.0.0) lib/oauth2/client.rb:138:in `get_token'
oauth2 (1.0.0) lib/oauth2/strategy/auth_code.rb:29:in `get_token'
omniauth-oauth2 (1.3.1) lib/omniauth/strategies/oauth2.rb:93:in `build_access_token'
omniauth-facebook (2.0.1) lib/omniauth/strategies/facebook.rb:115:in `build_access_token'
omniauth-oauth2 (1.3.1) lib/omniauth/strategies/oauth2.rb:77:in `callback_phase'
omniauth-facebook (2.0.1) lib/omniauth/strategies/facebook.rb:73:in `block in callback_phase'
omniauth-facebook (2.0.1) lib/omniauth/strategies/facebook.rb:136:in `with_authorization_code!'
omniauth-facebook (2.0.1) lib/omniauth/strategies/facebook.rb:72:in `callback_phase'
omniauth (1.2.2) lib/omniauth/strategy.rb:227:in `callback_call'
omniauth (1.2.2) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.2) lib/omniauth/builder.rb:59:in `call'
rack (1.5.5) lib/rack/etag.rb:23:in `call'
rack (1.5.5) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.5) lib/rack/head.rb:11:in `call'
Does anybody has the same?

Related

Apartment::TenantNotFound (Error while connecting to tenant 34: FATAL: database "34" does not exist

I am using ros-apartment gem for multi tenancy in rails application. I have deployed the application on AWS and sometime I get below error:
Apartment::TenantNotFound (Error while connecting to tenant 34: FATAL: database "34" does not exist):
And the backtrack of this error is:
ros-apartment (2.9.0) lib/apartment/adapters/abstract_adapter.rb:268:in `raise_connect_error!'
ros-apartment (2.9.0) lib/apartment/adapters/abstract_adapter.rb:189:in `rescue in connect_to_new'
ros-apartment (2.9.0) lib/apartment/adapters/abstract_adapter.rb:178:in `connect_to_new'
ros-apartment (2.9.0) lib/apartment/adapters/abstract_adapter.rb:76:in `block in switch!'
activesupport (5.2.0) lib/active_support/callbacks.rb:98:in `run_callbacks'
ros-apartment (2.9.0) lib/apartment/adapters/abstract_adapter.rb:75:in `switch!'
ros-apartment (2.9.0) lib/apartment/adapters/abstract_adapter.rb:88:in `switch'
ros-apartment (2.9.0) lib/apartment/elevators/generic.rb:22:in `call'
remotipart (1.4.2) lib/remotipart/middleware.rb:32:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (5.2.0) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call
Also I don't have the database with name 34, I have added Generic elevators to select the database from subdomain.
My tenant switching code in Generic elevator code in apartment.rb is as follows:
Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request|
_host = request.host.split('.').first
if ExcludedSubdomains.subdomains.include?(_host)
Rails.configuration.database_configuration[Rails.env]["database"]
else
_host
end
}
Because of this issue my server needs too long time to respond.
I am facing this issue because my host IP start from 34.xx.xx.xx as per code it return first subdomain it consider 34 is a first subdomain and because of that it search for 34 database and issue occcured

Rails. TinyMCE ImageUpload is requesting GET instead of POST as in Development

I am working on rails using TinyMCE Imageupload.
It works just fine in Development (funny enough it used to work also in Production). The problem is that on production it issues the wrong GET request:
ActionController::RoutingError (No route matches [GET] "/at/tinymce_assets"):
Two issues here: Firstly - it puts a locale in front, secondly it uses a GET request.
On development however it works fine:
Started POST "/tinymce_assets" for 127.0.0.1 at 2015-09-27 02:33:10 +0200
Processing by TinymceAssetsController#create as HTML
My routes.rb looks like this:
Rails.application.routes.draw do
root to: 'static_pages#redirect'
localized do
match '', to: 'static_pages#welcome', :as => 'welcome', via: 'get'
... lots of other stuff ...
end
match '*path', to: redirect("/#{I18n.locale}/%{path}"), constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" }, via: 'get'
post '/tinymce_assets/' => 'tinymce_assets#create', :trailing_slash => false
end
I am adding here the :trailing_slash => false - as it is set to true in environment.rb
Question:
Why does the production to site decide to fire a GET request + adding the locale, but the development does everything its supposed to do? Where can I set this behaviour ?
UPDATE - ADDING ADDITIONAL INFORMATION
After placing the post above my localized section I still get the same error - here the full trace:
I, [2015-09-28T16:32:07.614317 #6136] INFO -- : Started GET "/tinymce_assets/" for 82.84.80.128 at 2015-09-28 16:32:07 -0400
I, [2015-09-28T16:32:07.722280 #6136] INFO -- : Started GET "/at/tinymce_assets/" for 82.84.80.128 at 2015-09-28 16:32:07 -0400
F, [2015-09-28T16:32:07.726369 #6136] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/at/tinymce_assets"):
actionpack (4.1.12) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.1.12) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.12) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.12) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.12) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.12) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.12) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.12) lib/rails/rack/logger.rb:20:in `call'
request_store (1.2.0) lib/request_store/middleware.rb:8:in `call'
actionpack (4.1.12) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.5) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.12) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
railties (4.1.12) lib/rails/engine.rb:514:in `call'
railties (4.1.12) lib/rails/application.rb:144:in `call'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:94:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads'
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
If I add uploadimage_form_url: "/tinymce_assets" (again the post is on top) the same happens, except that it is now looking for the localized version:
ActionController::RoutingError (No route matches [GET] "/at/tinymce_assets"):
actionpack (4.1.12) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.1.12) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.12) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.12) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.12) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.12) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.12) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.12) lib/rails/rack/logger.rb:20:in `call'
request_store (1.2.0) lib/request_store/middleware.rb:8:in `call'
actionpack (4.1.12) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.5) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.12) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
railties (4.1.12) lib/rails/engine.rb:514:in `call'
railties (4.1.12) lib/rails/application.rb:144:in `call'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:94:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads'
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
The entire setup works on my local environment:
tinymce-rails (4.2.5)
tinymce-rails-imageupload (4.0.16.beta, 3.5.6.4)
OSX Yosemite 10.10.5
Rails 4.1.12
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]
The setup used to work, but not anylonger (after no apparent change - whilst I am currently also going through my GIT commits):
tinymce-rails (4.2.5)
tinymce-rails-imageupload (4.0.16.beta, 3.5.8.3)
Ubuntu 14.04.2 LTS
Rails 4.1.12
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux]
Here a full list of gems used in this application:
*** LOCAL GEMS ***
actionmailer (4.1.12)
actionpack (4.1.12)
actionview (4.1.12)
activemodel (4.1.12)
activerecord (4.1.12)
activesupport (4.1.12)
addressable (2.3.8)
arel (5.0.1.20140414130214)
bcrypt (3.1.10)
better_errors (2.1.1)
bigdecimal (1.2.4)
binding_of_caller (0.7.2)
bootstrap-datepicker-rails (1.4.0)
bootstrap-sass (3.1.1.1)
bootstrap-timepicker-rails (0.1.3)
bootstrap_form (2.3.0)
breadcrumbs_on_rails (2.3.1)
browser (1.0.1)
builder (3.2.2)
bundler (1.10.5)
cancancan (1.12.0)
capistrano (3.1.0)
capybara (2.5.0)
carrierwave (0.10.0)
chart-js-rails (0.0.8)
childprocess (0.5.6)
chronic (0.10.2)
climate_control (0.0.3)
cocaine (0.5.7)
cocoon (1.2.6)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (2.4.1)
coffee-script-source (1.9.1.1)
colorize (0.7.7)
config (1.0.0)
css_splitter (0.4.2)
database_cleaner (1.5.0)
debug_inspector (0.0.2)
deep_merge (1.0.1)
dependent-fields-rails (0.4.2)
devise (3.5.2)
diff-lcs (1.2.5)
domain_name (0.5.24)
dragonfly (0.9.15)
dropzonejs-rails (0.7.1)
erubis (2.7.0)
escape_utils (1.1.0)
execjs (2.6.0)
factory_girl (4.2.0)
factory_girl_rails (4.2.1)
faker (1.5.0)
fast_blank (1.0.0)
fast_stack (0.1.0)
ffi (1.9.10)
flamegraph (0.1.0)
font-awesome-rails (4.2.0.0)
friendly_id (5.1.0)
friendly_id-globalize (1.0.0.alpha2)
gaffe (1.0.2)
geocoder (1.2.10)
gli (2.13.2)
globalize (4.0.3)
globalize-accessors (0.1.5)
gmaps4rails (2.1.2)
gritter (1.1.0)
haml (4.0.7)
haml-rails (0.9.0)
html2haml (2.0.0)
http-cookie (1.0.2)
i18n (0.6.11)
io-console (0.4.3)
jbuilder (1.5.3)
jquery-fileupload-rails (0.4.5)
jquery-rails (3.1.4)
jquery-ui-rails (5.0.5)
json (1.8.3, 1.8.1)
launchy (2.4.3)
lazyload-rails (0.3.1)
libv8 (3.16.14.11 x86_64-linux)
localeapp (0.9.3)
mail (2.6.3)
mail_form (1.5.1)
maxminddb (0.1.8)
mime-types (2.6.1)
mimemagic (0.3.0)
mini_portile (0.6.2)
minitest (5.8.0, 4.7.5)
mobileesp_converted (0.2.3)
mobvious (0.3.2)
mobvious-rails (0.1.2)
modernizr-rails (2.7.1)
multi_json (1.11.2)
mysql2 (0.3.20)
net-scp (1.2.1)
net-ssh (2.9.2)
netrc (0.10.3)
nokogiri (1.6.6.2)
orm_adapter (0.5.0)
paper_trail (4.0.0)
paperclip (4.3.0)
papercrop (0.2.0)
pr_geohash (1.0.0)
psych (2.0.5)
pundit (1.0.1)
quiet_assets (1.1.0)
rack (1.5.5)
rack-cache (1.2)
rack-mini-profiler (0.9.7)
rack-test (0.6.3)
rails (4.1.12)
rails4-autocomplete (1.1.1)
rails_layout (1.0.26)
railties (4.1.12)
rake (10.4.2, 10.1.0)
rake-compiler (0.9.5)
rdoc (4.2.0, 4.1.0)
recaptcha (0.4.0)
redis (3.2.1)
redis-actionpack (4.0.1)
redis-activesupport (4.1.1)
redis-namespace (1.5.2)
redis-rack (1.5.0)
redis-rack-cache (1.2.2)
redis-rails (4.0.0)
redis-store (1.1.6)
ref (2.0.0)
request_store (1.2.0)
responders (1.1.2)
rest-client (1.8.0)
role_model (0.8.2)
route_downcaser (1.1.4)
route_translator (4.0.0)
rsolr (1.0.12)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
ruby_parser (3.7.1)
rubyzip (1.1.7)
sass (3.4.18)
sass-rails (5.0.4)
sdoc (0.4.1)
seed_dump (3.2.2)
selenium-webdriver (2.47.1)
settingslogic (2.0.9)
sexp_processor (4.6.0)
sitemap_generator (5.1.0)
sprockets (3.3.4)
sprockets-rails (2.3.3)
sshkit (1.7.1)
sunspot (2.2.0)
sunspot_rails (2.2.0)
sunspot_solr (2.2.0)
test-unit (2.1.6.0)
therubyracer (0.12.1)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
tinymce-rails (4.2.5)
tinymce-rails-imageupload (4.0.16.beta, 3.5.8.3)
tzinfo (1.2.2)
uglifier (2.7.2)
underscore-rails (1.8.3)
unf (0.1.4)
unf_ext (0.0.7.1)
videojs_rails (4.12.14)
warden (1.2.3)
websocket (1.2.2)
whenever (0.9.4)
wiselinks (1.2.1)
xpath (2.0.0)
ya2yaml (0.31)
Hope this helps to shed light into the situation. :)
Solution to the problem:
As I am rewriting and existing site and must keep the URL standards I have to keep the trailing slashes (which I do in Rails).
In my nginx site configuration I rewrote the URL's with a trailing slash, which for some reason turned into a two day masacre of narrowing down the issue.
Removing the trailing slash in the URL rewrite in nginx configuration
file solved the issue.
No jQuery sends POST requests again instead of GET requests !
Here for nginx (froala & tiny_mce and whatever you may use):
#Rewrite all URLs with missing slash and no period
location / {
rewrite ^([^.]*[^/])$ $1/ permanent;
}
#Keep your post url untouched
location /froala_upload {
rewrite $1 permanent;
}
location /tinymce_assets {
rewrite $1 permanent;
}
You should swap the last match '*path' line and the post '/tinymce_assets/' line. That will probably take care of it, or at least get you a bit further.
Routes in Rails match from the top, so match '*path' matches a POST to /tinymce_assets, sees it doesn't have a locale added, and does the redirect, via GET. Your application never reaches the line for post '/tinymce_assets'.

OmniAuth Login With Twitter - "Did not recognize your adapter specification." Error

I have been following railscast Login with Twitter using Omniauth tutorial.
http://railscasts.com/episodes/241-simple-omniauth
However, I am getting Did not recognize your adapter specification error.
You can find the Application error trace in the following.
By the way, I tried with both using multi_json 1.7.9 and multi_json 1.8.2:
ArgumentError (Did not recognize your adapter specification.):
multi_json (1.8.2) lib/multi_json.rb:108:in `rescue in load_adapter'
multi_json (1.8.2) lib/multi_json.rb:97:in `load_adapter'
multi_json (1.8.2) lib/multi_json.rb:101:in `load_adapter'
multi_json (1.8.2) lib/multi_json.rb:91:in `use'
multi_json (1.8.2) lib/multi_json.rb:73:in `adapter'
multi_json (1.8.2) lib/multi_json.rb:131:in `current_adapter'
multi_json (1.8.2) lib/multi_json.rb:118:in `load'
omniauth-twitter (1.0.1) lib/omniauth/strategies/twitter.rb:34:in `raw_info'
omniauth-twitter (1.0.1) lib/omniauth/strategies/twitter.rb:17:in `block in <class:Twitter>'
omniauth (1.1.4) lib/omniauth/strategy.rb:106:in `instance_eval'
omniauth (1.1.4) lib/omniauth/strategy.rb:106:in `block in compile_stack'
omniauth (1.1.4) lib/omniauth/strategy.rb:105:in `each'
omniauth (1.1.4) lib/omniauth/strategy.rb:105:in `inject'
omniauth (1.1.4) lib/omniauth/strategy.rb:105:in `compile_stack'
(eval):7:in `info_stack'
omniauth (1.1.4) lib/omniauth/strategy.rb:322:in `info'
omniauth (1.1.4) lib/omniauth/strategy.rb:335:in `auth_hash'
omniauth (1.1.4) lib/omniauth/strategy.rb:362:in `callback_phase'
omniauth-oauth (1.0.1) lib/omniauth/strategies/oauth.rb:58:in `callback_phase'
omniauth (1.1.4) lib/omniauth/strategy.rb:226:in `callback_call'
omniauth (1.1.4) lib/omniauth/strategy.rb:182:in `call!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.1.4) lib/omniauth/builder.rb:49:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.1) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.1) lib/active_support/callbacks.rb:373:in `_run__4245266409247275268__call__callbacks'
activesupport (4.0.1) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.1) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.1) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.1) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.1) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.0.1) lib/rails/engine.rb:511:in `call'
railties (4.0.1) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/usr/share/ruby/webrick/httpserver.rb:138:in `service'
/usr/share/ruby/webrick/httpserver.rb:94:in `run'
/usr/share/ruby/webrick/server.rb:191:in `block in start_thread
I had the same problem and I ran
gem cleanup
from the root of my app and followed it up by running
bundle install
It worked for me.

oauth-twitter is returning undefined method 'gsub' for nil:NilClass

I have a production app on heroku that relies on devise/oauth for login though either Facebook or Twitter. Login was working fine last night, but as of this morning, I can't login through twitter (facebook is working fine.)
I get 'gsub' for nil:NilClass both in development and in production on Heroku.
I did make a commit yesterday, but git reset --hard HEAD#{"number before yesterday"} does not fix the problem.
I'm not sure where to start with debugging this problem. Where should I be looking??
Here are my stack tace and bundled gems
stack trace
Started GET "/users/auth/twitter" for 127.0.0.1 at 2013-04-23 11:06:13 -0400
NoMethodError (undefined method `gsub' for nil:NilClass):
/Users/umezo/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/cgi/util.rb:7:in `escape'
oauth (0.4.7) lib/oauth/tokens/request_token.rb:28:in `block in build_authorize_url'
oauth (0.4.7) lib/oauth/tokens/request_token.rb:28:in `each'
oauth (0.4.7) lib/oauth/tokens/request_token.rb:28:in `map'
oauth (0.4.7) lib/oauth/tokens/request_token.rb:28:in `build_authorize_url'
oauth (0.4.7) lib/oauth/tokens/request_token.rb:9:in `authorize_url'
omniauth-oauth (1.0.1) lib/omniauth/strategies/oauth.rb:36:in `request_phase'
omniauth-twitter (0.0.14) lib/omniauth/strategies/twitter.rb:63:in `request_phase'
omniauth (1.1.1) lib/omniauth/strategy.rb:207:in `request_call'
omniauth (1.1.1) lib/omniauth/strategy.rb:174:in `call!'
omniauth (1.1.1) lib/omniauth/strategy.rb:157:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.3) lib/rack/etag.rb:23:in `call'
rack (1.4.3) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.3) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.3) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.11) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `_run__2832114944232593679__call__887588005576904267__callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.11) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.11) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.3) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.3) lib/rack/lock.rb:15:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.11) lib/rails/engine.rb:479:in `call'
railties (3.2.11) lib/rails/application.rb:223:in `call'
rack (1.4.3) lib/rack/content_length.rb:14:in `call'
railties (3.2.11) lib/rails/rack/log_tailer.rb:17:in `call'
thin (1.5.0) lib/thin/connection.rb:81:in `block in pre_process'
thin (1.5.0) lib/thin/connection.rb:79:in `catch'
thin (1.5.0) lib/thin/connection.rb:79:in `pre_process'
thin (1.5.0) lib/thin/connection.rb:54:in `process'
thin (1.5.0) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.0) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.0) lib/eventmachine.rb:187:in `run'
thin (1.5.0) lib/thin/backends/base.rb:63:in `start'
thin (1.5.0) lib/thin/server.rb:159:in `start'
rack (1.4.3) lib/rack/handler/thin.rb:13:in `run'
rack (1.4.3) lib/rack/server.rb:268:in `start'
railties (3.2.11) lib/rails/commands/server.rb:70:in `start'
railties (3.2.11) lib/rails/commands.rb:55:in `block in <top (required)>'
railties (3.2.11) lib/rails/commands.rb:50:in `tap'
railties (3.2.11) lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
Rendered /Users/umezo/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.9ms)
Rendered /Users/umezo/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.3ms)
Rendered /Users/umezo/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (18.4ms)
gems
Using rake (10.0.4)
Using i18n (0.6.1)
Using multi_json (1.5.0)
Using activesupport (3.2.11)
Using builder (3.0.4)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.3)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.2.2)
Using actionpack (3.2.11)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.11)
Using arel (3.0.2)
Using tzinfo (0.3.35)
Using activerecord (3.2.11)
Using activerecord-reputation-system (2.0.0)
Using activeresource (3.2.11)
Using addressable (2.3.2)
Using ancestry (1.3.0)
Using annotate (2.5.0)
Using multi_xml (0.5.1)
Using httparty (0.9.0)
Using json (1.7.6)
Using nokogiri (1.5.6)
Using uuidtools (2.1.3)
Using aws-sdk (1.3.9)
Using bcrypt-ruby (3.0.1)
Using sass (3.2.5)
Using bootstrap-sass (2.2.2.0)
Using will_paginate (3.0.3)
Using bootstrap-will_paginate (0.0.9)
Using ffi (1.3.0)
Using childprocess (0.3.6)
Using websocket (1.0.6)
Using libwebsocket (0.1.7.1)
Using rubyzip (0.9.9)
Using selenium-webdriver (2.27.2)
Using xpath (0.1.4)
Using capybara (1.1.2)
Using chunky_png (1.2.7)
Using orm_adapter (0.4.0)
Using ckeditor (3.7.3)
Using cocaine (0.3.2)
Using coderay (1.0.8)
Using coffee-script-source (1.4.0)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using rdoc (3.12)
Using thor (0.16.0)
Using railties (3.2.11)
Using coffee-rails (3.2.2)
Using fssm (0.2.9)
Using compass (0.12.2)
Using compass-rails (1.0.3)
Using daemons (1.1.9)
Using dalli (2.6.2)
Using warden (1.2.1)
Using devise (2.2.0)
Using diff-lcs (1.1.3)
Using eventmachine (1.0.0)
Using factory_girl (4.1.0)
Using factory_girl_rails (4.1.0)
Using faker (1.1.2)
Using multipart-post (1.1.5)
Using faraday (0.8.4)
Using friendly_id (4.0.9)
Using growl (1.0.3)
Using listen (0.7.1)
Using lumberjack (1.0.2)
Using method_source (0.8.1)
Using slop (3.3.3)
Using pry (0.9.10)
Using guard (1.6.1)
Using guard-rspec (1.2.1)
Using spork (0.9.2)
Using sys-proctable (0.9.2)
Using guard-spork (1.2.0)
Using hashie (1.2.0)
Using httpauth (0.2.0)
Using jquery-rails (2.1.4)
Using jquery-ui-rails (4.0.2)
Using jwt (0.1.5)
Using oauth (0.4.7)
Using oauth2 (0.8.0)
Using omniauth (1.1.1)
Using omniauth-oauth2 (1.1.1)
Using omniauth-facebook (1.4.1)
Using omniauth-oauth (1.0.1)
Using omniauth-twitter (0.0.14)
Using paperclip (3.1.4)
Using pg (0.14.1)
Using bundler (1.2.1)
Using rails (3.2.11)
Using rb-fsevent (0.9.1)
Using rspec-core (2.11.1)
Using rspec-expectations (2.11.3)
Using rspec-mocks (2.11.3)
Using rspec (2.11.0)
Using rspec-rails (2.11.0)
Using sass-rails (3.2.5)
Using simple_form (2.0.4)
Using thin (1.5.0)
Using uglifier (1.3.0)
There's an open issue at gem's GitHub repo page.
See https://github.com/arunagw/omniauth-twitter/issues/30
nevermind, it's working again... ;)
I'm assuming this means it was an issue with twitter, as opposed to with my app.
However, any input regarding how to diagnose an issue like this would be appreciated.

omniauth callback timeout

I used sample of https://github.com/igaiga/omniauth-sample, it just stucked at the callback phase.
I've also tested some other samples, the result were same.
Started GET "/auth/facebook/callback?state=118c21d7ea5675990e0a5e8a876f041f59dbc9a925f94754&code=AQDp93hH-WQor4ZQ8S_ZIGw0dTARw5vPMmkNAiRW9Ql8n7-fny0R5Du88InAILPbXUmdwWh_MyMpZzHzhO2YSlDXeMclSdyDfQQbtlFqixnYgpFt_3Sx5DETKIAYj2amRhK6JaNvxT1ffXgJ6qbMfHUbXlaerFWep60RVHBqwdA6tS-AoPQBNbKSA52-YAhj9-McGoEl4LQi4PGkIpVZu9IV" for 127.0.0.1 at 2013-04-07 16:51:24 +0800
Errno::ETIMEDOUT (Operation timed out - SSL_connect):
/Users/mac/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:799:in `connect'
/Users/mac/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:799:in `block in connect'
/Users/mac/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
/Users/mac/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
/Users/mac/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:799:in `connect'
/Users/mac/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
/Users/mac/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:744:in `start'
/Users/mac/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:1284:in `request'
faraday (0.8.7) lib/faraday/adapter/net_http.rb:75:in `perform_request'
faraday (0.8.7) lib/faraday/adapter/net_http.rb:38:in `call'
faraday (0.8.7) lib/faraday/request/url_encoded.rb:14:in `call'
faraday (0.8.7) lib/faraday/connection.rb:247:in `run_request'
oauth2 (0.8.1) lib/oauth2/client.rb:88:in `request'
oauth2 (0.8.1) lib/oauth2/client.rb:131:in `get_token'
oauth2 (0.8.1) lib/oauth2/strategy/auth_code.rb:29:in `get_token'
omniauth-oauth2 (1.1.1) lib/omniauth/strategies/oauth2.rb:99:in `build_access_token'
omniauth-facebook (1.4.1) lib/omniauth/strategies/facebook.rb:73:in `block in build_access_token'
omniauth-facebook (1.4.1) lib/omniauth/strategies/facebook.rb:174:in `with_authorization_code!'
omniauth-facebook (1.4.1) lib/omniauth/strategies/facebook.rb:73:in `build_access_token'
omniauth-oauth2 (1.1.1) lib/omniauth/strategies/oauth2.rb:74:in `callback_phase'
omniauth (1.1.3) lib/omniauth/strategy.rb:219:in `callback_call'
omniauth (1.1.3) lib/omniauth/strategy.rb:175:in `call!'
omniauth (1.1.3) lib/omniauth/strategy.rb:157:in `call'
omniauth (1.1.3) lib/omniauth/strategy.rb:177:in `call!'
omniauth (1.1.3) lib/omniauth/strategy.rb:157:in `call'
omniauth (1.1.3) lib/omniauth/builder.rb:48:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_
The reason is I'm behind the GFW of china. For some reason goagent does not help in this problem, and vpn only helps in case of facebook. The good news is when I deployed the codes to heroku it works for both facebook and twitter.

Resources