This is my first Sinatra project, and I'm pretty late, and I understand that when you make multiple queries that use ActiveRecord, I run into problems. If I make only one request, each of them will work on its own. But when I call both at once, I get a refusal.
So far, I have narrowed it down to two ActiveRecord concurrent queries. Maybe I did not configure ActiveRecord correctly? I use PostgreSQL because Heroku uses it and I am not prone to change. (The problem also occurs on Heroku.)
Here is the log:
192.168.1.113 - - [30/Sep/2012:10:33:00 MDT] "GET /version/current?platform=android HTTP/1.1" 200 33 - -> /version/current?platform=android ActiveRecord::StatementInvalid - NoMethodError: undefined method `fields' for nil:NilClass: SELECT "rankings".* FROM "rankings" WHERE "rankings"."user_id" = 1 LIMIT 1: /Users/zablanc/.rvm/gems/ ruby-1.9.3-head@emm /gems/activerecord-3.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:667:in `block in exec_query' ... Warning! Rack::Session::Cookie data size exceeds 4K. Warning! Rack::Session::Cookie failed to save session. Content dropped. 192.168.1.113 - - [30/Sep/2012:10:33:01 MDT] "GET /badges/all HTTP/1.1" 200 311 - -> /badges/all 192.168.1.113 - - [30/Sep/2012:10:33:01 MDT] "GET /moves/ranking/all HTTP/1.1" 500 166185 - -> /moves/ranking/all
I have no idea how to plug these warnings in a cookie, as they do not seem to affect the application. Here's how I configure my application (in the configuration file, which is required from the main script):
enable :logging use ActiveRecord::ConnectionAdapters::ConnectionManagement use Rack::Session::Cookie, :key => 'rack.session', :path => '/', :expire_after => 31_536_000,
I assume that I am not setting up ActiveRecord correctly, but I think that this is exactly the same as the tutorials that I saw. What gives?
source share