I have a weird problem, every page of my website that contains database queries loads some extra items. I've never had this problem before, tried to check all controllers but haven't found any problems. Here is an example of output when I load (or refresh) home page:
=> Booting Puma
=> Rails 5.1.6 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.5.0-p0), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Started GET "/c/wines" for 127.0.0.1 at 2018-11-02 15:55:30 -0400 (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by CatalogsController#show as HTML
Parameters: {"id"=>"wines"}
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."slug" = ? LIMIT ? [["slug", "wines"], ["LIMIT", 1]]
Rendering catalogs/show.html.haml within layouts/application (0.2ms) SELECT COUNT(*) FROM "categories" WHERE "categories"."catalog_id" = ? [["catalog_id", 1]] (0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Category Exists (0.3ms) SELECT 1 AS one FROM "categories" WHERE "categories"."catalog_id" = 1 AND "categories"."open" = ? LIMIT ? [["open", "t"], ["LIMIT", 1]]
Category Load (0.9ms) SELECT "categories".* FROM "categories" WHERE "categories"."catalog_id" = 1 AND "categories"."open" = ? [["open", "t"]]
CACHE Category Load (0.0ms) SELECT "categories".* FROM "categories" WHERE "categories"."catalog_id" = 1 AND "categories"."open" = ? [["open", "t"]]
CACHE Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."catalog_id" = 1 AND "categories"."open" = ? [["open", "t"]]
Product Load (0.8ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 AND "products"."open" = ? AND "products"."category_id" = 1 [["open", "t"]]
Catalog Load (0.7ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 AND "products"."open" = ? AND "products"."category_id" = 2 [["open", "t"]]
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
Rendered catalogs/show.html.haml within layouts/application (142.7ms)
Rendered application/_favicon.html.haml (11.1ms)
Catalog Load (0.4ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_navbar.html.haml (23.7ms)
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_footer.html.haml (15.7ms)
Completed 200 OK in 937ms (Views: 890.8ms | ActiveRecord: 9.4ms)
Started GET "/uploads/catalog/photo/1/hero-8.png" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Started GET "/" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Processing by StaticController#home as HTML
Started GET "/uploads/product/photo/4/pc_pistachio.png" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Started GET "/uploads/product/photo/7/pc_pistachio.png" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Started GET "/uploads/product/photo/1/pc_creame.png" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Started GET "/uploads/product/photo/10/pc_pistachio.png" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Rendering static/home.html.haml within layouts/application
Catalog Load (0.3ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? ORDER BY created_at ASC LIMIT ? [["open", "t"], ["LIMIT", 6]]
(0.3ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Product Exists (0.4ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 1]]
Product Load (0.9ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1, 2)
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 2
Product Exists (0.2ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 1]]
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 2
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 3
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 3
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 1]]
Product Load (0.1ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 3
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 2
Rendered static/home.html.haml within layouts/application (95.0ms)
Rendered application/_favicon.html.haml (15.0ms)
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_navbar.html.haml (19.9ms)
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_footer.html.haml (18.0ms)
Completed 200 OK in 400ms (Views: 389.1ms | ActiveRecord: 4.3ms)
Started GET "/" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Started GET "/" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Processing by StaticController#home as HTML
Started GET "/" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Started GET "/" for 127.0.0.1 at 2018-11-02 15:55:31 -0400
Processing by StaticController#home as HTML
Rendering static/home.html.haml within layouts/application
Processing by StaticController#home as HTML
Catalog Load (0.5ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? ORDER BY created_at ASC LIMIT ? [["open", "t"], ["LIMIT", 6]]
Rendering static/home.html.haml within layouts/application
Processing by StaticController#home as HTML
Catalog Load (0.4ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? ORDER BY created_at ASC LIMIT ? [["open", "t"], ["LIMIT", 6]]
Rendering static/home.html.haml within layouts/application
(0.3ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 1]]
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? ORDER BY created_at ASC LIMIT ? [["open", "t"], ["LIMIT", 6]]
(0.1ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Product Exists (0.2ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 1]]
Rendering static/home.html.haml within layouts/application
(0.4ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? ORDER BY created_at ASC LIMIT ? [["open", "t"], ["LIMIT", 6]]
Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 6]]
(0.1ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1, 2)
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Product Exists (0.2ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 1]]
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1, 2)
Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 6]]
Product Exists (0.4ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 1]]
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 2
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 1]]
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 2
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 3
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 3
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 1]]
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 2
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 6]]
Product Exists (0.4ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 1]]
Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 2
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 6]]
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1, 2)
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 2
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1, 2)
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 2
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 1]]
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 2
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 3
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 3
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 1]]
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 3
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 1]]
Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 3
Catalog Load (0.4ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 3
Product Load (0.6ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 6]]
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 3
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 1]]
Product Load (0.1ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 3
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 2
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 2
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 3
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 2
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 2
Rendered static/home.html.haml within layouts/application (206.4ms)
Rendered application/_favicon.html.haml (6.5ms)
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 3
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 1]]
Product Load (0.1ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 3
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 2
Rendered static/home.html.haml within layouts/application (195.5ms)
Rendered application/_favicon.html.haml (0.1ms)
Rendered static/home.html.haml within layouts/application (246.3ms)
Rendered static/home.html.haml within layouts/application (255.3ms)
Rendered application/_favicon.html.haml (0.1ms)
Rendered application/_favicon.html.haml (0.0ms)
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_navbar.html.haml (13.9ms)
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_footer.html.haml (9.7ms)
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_navbar.html.haml (3.2ms)
Catalog Load (0.3ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_navbar.html.haml (3.2ms)
Rendered shared/_navbar.html.haml (14.3ms)
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_footer.html.haml (5.9ms)
Rendered shared/_footer.html.haml (3.0ms)
Rendered shared/_footer.html.haml (6.0ms)
Completed 200 OK in 859ms (Views: 853.1ms | ActiveRecord: 3.5ms)
Completed 200 OK in 802ms (Views: 795.7ms | ActiveRecord: 4.0ms)
Completed 200 OK in 849ms (Views: 842.5ms | ActiveRecord: 3.7ms)
Started GET "/" for 127.0.0.1 at 2018-11-02 15:55:32 -0400
Processing by StaticController#home as HTML
Completed 200 OK in 858ms (Views: 851.2ms | ActiveRecord: 3.8ms)
Rendering static/home.html.haml within layouts/application
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? ORDER BY created_at ASC LIMIT ? [["open", "t"], ["LIMIT", 6]]
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Product Exists (0.3ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 1]]
Product Load (0.6ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.4ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1, 2)
(0.5ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 2
Product Exists (0.2ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 1]]
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 2
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 3
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 3
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 1]]
Product Load (0.4ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.3ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 3
Category Load (0.5ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 2
Rendered static/home.html.haml within layouts/application (58.7ms)
Rendered application/_favicon.html.haml (9.7ms)
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_navbar.html.haml (16.9ms)
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_footer.html.haml (11.7ms)
Completed 200 OK in 261ms (Views: 254.4ms | ActiveRecord: 4.7ms)
My Static controller:
class StaticController < ApplicationController
def home
#catalogs = Catalog.all.where(open: true).order('created_at ASC').limit(6)
# #products = Product.all.includes(:catalog, :category).where(open: true).order('created_at DESC').take(8)
end
def about
#catalogs = Catalog.all.where(open: true)
#categories = Category.all.where(open: true)
#products = Product.all.where(open: true)
end
def download_pdf
send_file "#{Rails.root}/app/assets/docs/1_s.pdf", type: "application/pdf", x_sendfile: true
end
end
Note: I have similar problems with other controllers
At the beginning I thought that it's a bag because I didn't add any new code. Please, let me know if you need more code from controllers. Thank you very much for your time and help.
UPDATE
Application Controller:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :prepare_meta_tags, if: "request.get?"
def prepare_meta_tags(options={})
site_name = "Alvian Imports Inc."
title = "Alvain Imports Inc."
description = "For many years, Alvian imports alcohol accross Florida state and now it's time to grow. Absolutly new team with new products that will be loved by everyone. We have an exclusive partnership with Ponche Caribe and we are starting to deliver our products to Texas, California, Mexico, and Columbia. Our goal is to make alcohol importation better and faster, so our team is working hard to deliver wonderful products to your closest stores."
image = options[:image] || "app/assets/images/brand/logo.png"
current_url = request.url
# Let's prepare a nice set of defaults
defaults = {
site: site_name,
title: title,
image: image,
description: description,
keywords: %w[food food processor food service food and drink f&b food industry food and beverage service food & beverage food processing industry food and beverage manager food and beverage industry food service jobs food beverage beverage industry food service companies f&b service food service worker food industry jobs food service industry food & drink food drink food and beverage management types of food service f&b industry food and beverage department import imports alvian alvianimports miami usa florida],
twitter: {
site_name: site_name,
site: '#IncAlvian',
card: 'The Beverage Company. Ponche Caribe Curacao Blue & Liquors Exclusive Distributor Florida - Texas - California - Colombia Distributor. Must be 21 +',
description: description,
image: image
},
og: {
url: current_url,
site_name: site_name,
title: title,
image: image,
description: description,
type: 'website'
}
}
options.reverse_merge!(defaults)
set_meta_tags options
end
end
Application.html.haml code:
!!!
%html(lang="en-US" class="region--#{controller.controller_name}")
%head
= display_meta_tags
%meta(http-equiv="X-UA-Compatible" content="IE=edge,chrome=1")
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%meta{:charset => "utf-8"}/
%meta{:content => "width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no", :name => "viewport"}/
%meta{:content => "user-scalable=no, width=device-width, initial-scale=1.0", :name => "viewport"}/
%meta{:content => "yes", :name => "apple-mobile-web-app-capable"}/
%meta{:'http-equiv' => "X-UA-Compatible", :content => "IE=edge"}
%meta{:name => "HandheldFriendly", :contnet => "true"}
%meta{:name => "MobileOptimized", :content => "176"}
= render 'application/favicon'
%title #{content_for?(:title) ? yield(:title) : 'Alvian Imports'}
= csrf_meta_tags
= stylesheet_link_tag 'application', media: 'all'
= analytics_init if GoogleAnalytics.valid_tracker?
%body(class = '#{controller.controller_name}')
%div(class="application-wrapper")
= render partial: 'shared/navbar'
= content_tag :main, class: "layout layout-#{controller.action_name}" do
= yield
= render partial: 'shared/footer'
- unless params[:nojs]
= javascript_include_tag 'application'
UPDATE 2
I have 3 models: Catalog, Category, and Products.
Catalog model:
class Catalog < ApplicationRecord
extend FriendlyId
friendly_id :name, use: [:slugged, :history]
mount_uploader :photo, PhotoUploader
has_many :categories, dependent: :delete_all
has_many :products, :through => :categories, :source => :catalog, dependent: :delete_all
# Important fields
validates_presence_of :name
end
Category model:
class Category < ApplicationRecord
extend FriendlyId
friendly_id :name, use: [:slugged, :history]
belongs_to :catalog, :foreign_key => 'catalog_id'
has_many :products, dependent: :delete_all
# Important fields
validates_presence_of :name
def self.active
where(status: 1)
end
end
Product model:
class Product < ApplicationRecord
extend FriendlyId
friendly_id :name, use: [:slugged, :history]
mount_uploader :photo, PhotoUploader
belongs_to :catalog, :foreign_key => 'catalog_id'
belongs_to :category, :foreign_key => 'category_id'
# Important fields
validates_presence_of :name
end
Expected output in the console:
Started GET "/" for 127.0.0.1 at 2018-11-02 16:41:26 -0400
Processing by StaticController#home as HTML
Rendering static/home.html.haml within layouts/application
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? ORDER BY created_at ASC LIMIT ? [["open", "t"], ["LIMIT", 6]]
(0.1ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 1
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 1]]
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 1 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 1
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1, 2)
(0.2ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 2
Product Exists (0.1ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 1]]
Product Load (0.1ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 2 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.1ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 2
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 3
(0.3ms) SELECT COUNT(*) FROM "products" WHERE "products"."catalog_id" = 3
Product Exists (0.3ms) SELECT 1 AS one FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 1]]
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."catalog_id" = 3 LIMIT ? [["LIMIT", 6]]
Catalog Load (0.3ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."id" = 3
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = 2
Rendered static/home.html.haml within layouts/application (44.4ms)
Rendered application/_favicon.html.haml (7.9ms)
Catalog Load (0.2ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_navbar.html.haml (15.8ms)
CACHE Catalog Load (0.0ms) SELECT "catalogs".* FROM "catalogs" WHERE "catalogs"."open" = ? [["open", "t"]]
Rendered shared/_footer.html.haml (8.9ms)
Completed 200 OK in 218ms (Views: 213.2ms | ActiveRecord: 3.1ms)
Home page HTML (HAML), however it has to be mentioned that I get similar problem with other pages that requires queries (for example catalog show pages):
= content_for :navbar_class, "navbar-dark"
%section(class="hero hero-homepage")
%div(class="hh-container")
%div(class="hh-carousel")
- #catalogs.each do |catalog|
%div(class="hhc-item")
= link_to catalog, class: 'hhc-container' do
%div(class="hhc-background" style="background-image: url(#{catalog.photo});")
-# = image_tag(catalog.photo, lazy: true, class: "hhc-background")
%div(class="hhc-caption")
%h4(class="heading heading-1 is-light") #{catalog.name}
- if !catalog.description.empty?
%p(class="text text-2 is-light is-transparent") #{truncate(catalog.description, :length => 112)}
%section(class="section")
- #catalogs.each do |pc|
- #products = Product.all.where(catalog_id: pc)
%div(class="content")
%div(class="header header-hr")
%span
%h4(class="heading heading-4") New #{pc.name}
- if #products.count > 6
%span
= link_to "View all " + #products.count.to_s, pc, class: "link link-secondary link-arrow"
%div(class="row")
- if !#products.empty?
- #products.includes(:catalog, :category).take(6).each do |p|
%div(class="col-xs-6 col-md-4 col-lg-3")
= link_to catalog_category_product_url(p.catalog, p.category, p), class: "block block-product" do
= image_tag p.photo, alt: p.name, class: 'bp-photo', lazy: true
%div(class="bp-desc")
%span
%h5(class="heading heading-5") #{p.name}
%span
%p(class="text text-3")
%span.is-primary #{p.catalog.name}
%span - #{p.category.name}
- else
%div(class="col-xs-12 is-centered")
%h5(class="heading heading-5") Currently this list is empty.
UPDATE 3
Ok, I didn't understand the course of the problem but I decided to recreate the database:
rake db:drop db:create db:migrate
Fixed the problem..
A whole bunch of things and hard to help without actually running the code.
First of all, familiarize yourself with good practice in regards of naming things.
#catalogs.each do |pc| is a no-no and should be #catalogs.each do |catalog|.
if !#products.empty? and #product.count, those trigger two queries and my recommendation is to write the count into #products_count and replace that empty? with #product_count > 0
Use scope in the model to replace things like .where(open: true)
In #products.includes(:catalog, :category) you can remove the catalog because you already walk the products by catalog and can use pc (or as I recommended above: catalog) instead of product.catalog
If catalog_category_product_url doesn't use anything fancy but just the ids (e.g. catalog/5/category/2/product/23) then you can do catalog_category_product_url(product.catalog_id, product.category_id, product) to prevent a few extra queries (especially if you forgot to use eager loading or don't want to load a big chunk of data from the db).
Today I was attempting to set up caching using ActiveModelSerializers. I was having a lot of problems (my connection kept timing out). So I attempted to revert all my changes, including deleting the branch I was working on.
However, ever since I tried to set up caching, the model I was working with has exhibited strange behavior. It looks like it's still loading the cache elements. This is causing a huge performance hit when trying to access the endpoint for that model.
Started GET "/api/v1/entities" for ::1 at 2016-11-17 16:50:44 -0700
ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by Api::V1::EntitiesController#index as JSON
Entity Load (0.4ms) SELECT "entities".* FROM "entities" ORDER BY "entities"."name" ASC
Group Load (0.3ms) SELECT "groups".* FROM "groups" WHERE "groups"."id" IN (2, 3, 1) ORDER BY "groups"."name" ASC
Platform Load (0.4ms) SELECT "platforms".* FROM "platforms" WHERE "platforms"."id" IN (3, 8) ORDER BY "platforms"."name" ASC
HardwareType Load (19.3ms) SELECT "hardware_types".* FROM "hardware_types" WHERE "hardware_types"."id" IN (1, 3, 19, 8)
EntityType Load (0.2ms) SELECT "entity_types".* FROM "entity_types" WHERE "entity_types"."id" IN (1)
EntityOperationalState Load (0.4ms) SELECT "entity_operational_states".* FROM "entity_operational_states" WHERE "entity_operational_states"."entity_id" IN (1, 2, 3, 4)
OperationalState Load (0.2ms) SELECT "operational_states".* FROM "operational_states" WHERE "operational_states"."id" IN (1) ORDER BY "operational_states"."name" ASC
EntityLifecycleState Load (0.4ms) SELECT "entity_lifecycle_states".* FROM "entity_lifecycle_states" WHERE "entity_lifecycle_states"."entity_id" IN (1, 2, 3, 4)
LifecycleState Load (0.3ms) SELECT "lifecycle_states".* FROM "lifecycle_states" WHERE "lifecycle_states"."id" IN (2) ORDER BY "lifecycle_states"."name" ASC
IpAddress Load (0.3ms) SELECT "ip_addresses".* FROM "ip_addresses" WHERE "ip_addresses"."entity_id" IN (1, 2, 3, 4)
IpType Load (0.2ms) SELECT "ip_types".* FROM "ip_types" WHERE "ip_types"."id" IN (1)
IpUse Load (0.4ms) SELECT "ip_uses".* FROM "ip_uses" WHERE "ip_uses"."id" IN (1, 2)
[active_model_serializers] Entity Load (0.3ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = ? ORDER BY "entities"."name" ASC LIMIT 1 [["id", 1]]
[active_model_serializers] CACHE (0.0ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = ? ORDER BY "entities"."name" ASC LIMIT 1 [["id", 1]]
[active_model_serializers] Entity Load (0.2ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = ? ORDER BY "entities"."name" ASC LIMIT 1 [["id", 2]]
[active_model_serializers] CACHE (0.0ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = ? ORDER BY "entities"."name" ASC LIMIT 1 [["id", 2]]
[active_model_serializers] Entity Load (0.2ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = ? ORDER BY "entities"."name" ASC LIMIT 1 [["id", 3]]
[active_model_serializers] CACHE (0.0ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = ? ORDER BY "entities"."name" ASC LIMIT 1 [["id", 3]]
[active_model_serializers] Rendered ActiveModel::Serializer::CollectionSerializer with ActiveModelSerializers::Adapter::Json (71.13ms)
Completed 200 OK in 617ms (Views: 474.3ms | ActiveRecord: 27.8ms)
The [active_model_serializers] Load and CACHE are the new things that lead me to believe the serializer still attempting to load from cache.
My other models, which I didn't touch load with just one [active_model_serializers] statement, which is the behavior I expected.
Started GET "/api/v1/groups" for ::1 at 2016-11-17 16:56:15 -0700
Processing by Api::V1::GroupsController#index as JSON
Group Load (0.2ms) SELECT "groups".* FROM "groups" ORDER BY "groups"."name" ASC
Platform Load (0.3ms) SELECT "platforms".* FROM "platforms" WHERE "platforms"."id" IN (8, 3) ORDER BY "platforms"."name" ASC
GroupOperationalState Load (0.2ms) SELECT "group_operational_states".* FROM "group_operational_states" WHERE "group_operational_states"."group_id" IN (1, 2, 3)
OperationalState Load (0.2ms) SELECT "operational_states".* FROM "operational_states" WHERE "operational_states"."id" IN (1) ORDER BY "operational_states"."name" ASC
GroupLifecycleState Load (0.4ms) SELECT "group_lifecycle_states".* FROM "group_lifecycle_states" WHERE "group_lifecycle_states"."group_id" IN (1, 2, 3)
LifecycleState Load (0.2ms) SELECT "lifecycle_states".* FROM "lifecycle_states" WHERE "lifecycle_states"."id" IN (2) ORDER BY "lifecycle_states"."name" ASC
GroupConfigurationProfile Load (0.3ms) SELECT "group_configuration_profiles".* FROM "group_configuration_profiles" WHERE "group_configuration_profiles"."group_id" IN (1, 2, 3)
ConfigurationProfile Load (0.3ms) SELECT "configuration_profiles".* FROM "configuration_profiles" WHERE "configuration_profiles"."id" IN (1, 2, 3) ORDER BY "configuration_profiles"."name" ASC
[active_model_serializers] Rendered ActiveModel::Serializer::CollectionSerializer with ActiveModelSerializers::Adapter::Json (1.4ms)
Completed 200 OK in 51ms (Views: 36.3ms | ActiveRecord: 2.1ms)
Started GET "/api/v1/ip_addresses" for ::1 at 2016-11-17 16:58:34 -0700
Processing by Api::V1::IpAddressesController#index as JSON
IpAddress Load (0.2ms) SELECT "ip_addresses".* FROM "ip_addresses"
Entity Load (0.3ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" IN (1, 2, 3) ORDER BY "entities"."name" ASC
IpUse Load (0.2ms) SELECT "ip_uses".* FROM "ip_uses" WHERE "ip_uses"."id" IN (1, 2)
IpType Load (0.1ms) SELECT "ip_types".* FROM "ip_types" WHERE "ip_types"."id" IN (1)
[active_model_serializers] Rendered ActiveModel::Serializer::CollectionSerializer with ActiveModelSerializers::Adapter::Json (2.85ms)
Completed 200 OK in 28ms (Views: 14.8ms | ActiveRecord: 0.9ms)
Those extra trips to the db are slowing down my load times, as you can see. These models all have around 3 objects right now, but when I was testing with many more records, this becomes a huge problem.
How can I force ActiveModelSerializer to either ignore the cached items?
A better option would be to figure out where those fragments were cached, so I can clear them out. I tried Rails.cache.clear, but this has no effect. I also tried, rebooting the computer, and also shutting down my Redis instance.
Never mind. Apparently this has nothing to do with the caching work I was doing.
I had a circular reference to the entity name in my has_many relationship
I finished few minutes ago my project. I made a commit, after this I wanted to clear DB because there was many testing records. So I ran this in my DBconsole:
sqlite> delete from users where id;
sqlite> delete from users where id=1;
sqlite> delete from posts where id=1;
sqlite> delete from votes where id=1;
After this my project didn't work(((. It returns:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
On every page, even statics!!!!
I need my project to tomorrow. I restored from Git, but error is not disappeared.
My logs see like this:
Started GET "/" for 127.0.0.1 at 2014-03-14 04:08:40 +0200
Processing by PostsController#index as HTML
(0.4ms) SELECT COUNT(*) FROM "posts" WHERE "posts"."statut" = 1
(0.3ms) SELECT COUNT(*) FROM "posts" WHERE "posts"."statut" = 2
(0.4ms) SELECT COUNT(*) FROM "posts" WHERE ("posts"."statut" BETWEEN 3 AND 4)
Post Load (0.7ms) SELECT "posts".* FROM "posts" WHERE "posts"."statut" = 1 ORDER BY created_at DESC LIMIT 10
Post Load (0.6ms) SELECT "posts".* FROM "posts" WHERE "posts"."statut" = 2 ORDER BY created_at DESC LIMIT 10
Post Load (0.5ms) SELECT "posts".* FROM "posts" WHERE ("posts"."statut" BETWEEN 3 AND 4) ORDER BY created_at DESC LIMIT 10
Rendered posts/index.html.erb within layouts/application (23.5ms)
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE "posts"."statut" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE "posts"."statut" = 2
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE ("posts"."statut" BETWEEN 3 AND 4)
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE "posts"."statut" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE "posts"."statut" = 2
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE ("posts"."statut" BETWEEN 3 AND 4)
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE "posts"."statut" = 1
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE "posts"."statut" = 2
CACHE (0.0ms) SELECT COUNT(*) FROM "posts" WHERE ("posts"."statut" BETWEEN 3 AND 4)
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 8]]
Completed 500 Internal Server Error in 74ms
This is for main page. Help me!! I can give u a git, I need to repair it, please.
You deleted all your users with this statement.
delete from users where id;
So the line in the log
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 8]]
Won't be able to load user with id 8 because the table is empty. Maybe you need to add back a user crucial for your program to function.
I'm trying to update a model object, and it keeps rolling back. Occassionaly protesting that it is a validation error. But it doesn't point to what is actually failing.
In the end, I tried to delete it, but in the deletion, it still fails validation.
Is there a way to debug this and find out exactly why/what is causing this?
Thanks
A typical response to an update or delete:
ActiveRecord::RecordNotSaved: ActiveRecord::RecordNotSaved
from /data/HQ_Channel2/releases/20111011173855/vendor/rails/activerecord/lib/active_record/base.rb:2551:in `save_without_validation!'
from /data/HQ_Channel2/releases/20111011173855/vendor/rails/activerecord/lib/active_record/validations.rb:1019:in `save_without_dirty!'
from /data/HQ_Channel2/releases/20111011173855/vendor/rails/activerecord/lib/active_record/dirty.rb:87:in `save_without_transactions!'
from /data/HQ_Channel2/releases/20111011173855/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!'
from /data/HQ_Channel2/releases/20111011173855/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
And for more evidence, this is the stack from the appication when I try to create a new object:
Processing OrganizationsController#create (for 127.0.0.1 at 2011-10-12 15:43:02) [POST]
Parameters: {"commit"=>"submit", "action"=>"create", "authenticity_token"=>"QxTT80hdtULmkt7PeUH5MG+BZ/5l+a22ry3EL49q1V8=", "controller"=>"organizations", "organization"=>{"city"=>"lkjlkj", "name"=>"asdfa", "contact_24"=>"1", "zip"=>"123123", "quick_description"=>"2342, 123, 3,2423, 2", "url"=>"www.martini494bistro.com/", "hq_url"=>"12341234", "map_it"=>"1", "street"=>"lkjlkj", "phone_work"=>"123123123123", "is_authorized"=>"1", "state"=>"NJ"}}
User Columns (2.2ms) SHOW FIELDS FROM `users`
User Load (4.4ms) SELECT * FROM `users` WHERE (`users`.`persistence_token` = '77ca6dea2961c5102be62d8e995e3f4bfdcb5bcfdf64a4e8361d2f3b49e9b377e6467d1a01a3fbe7fc6dab76382220b044d3782f6045130a2de047d8b8f0bd87') LIMIT 1
SQL (0.1ms) BEGIN
User Update (0.3ms) UPDATE `users` SET `updated_at` = '2011-10-12 19:43:02', `perishable_token` = 'YP8Ivses9OgR6LtrNBvF', `last_request_at` = '2011-10-12 19:43:02' WHERE `id` = 2953
Solr Update (7.0ms) <?xml version="1.0" encoding="UTF-8"?><add><doc><field name="type">User</field><field name="type">ActiveRecord::Base</field><field name="id">User 2953</field><field name="email_s">asdfasdf#asdfasdf.com</field><field name="name_s">asdfadsf adfasdf</field><field name="first_name_s">asdfadsf</field><field name="created_at_d">2011-10-12T19:39:36Z</field><field name="class_name">User</field><field name="last_name_s">adfasdf</field><field name="name_text">asdfadsf adfasdf</field><field name="email_text">asdfasdf#asdfasdf.com</field><field name="last_name_text">adfasdf</field><field name="first_name_text">asdfadsf</field></doc></add>
SQL (0.6ms) COMMIT
SQL (1.1ms) SHOW TABLES
Organization Columns (5.4ms) SHOW FIELDS FROM `organizations`
Organization Load (2.9ms) SELECT `organizations`.* FROM `organizations` INNER JOIN `organizations_users` ON `organizations`.id = `organizations_users`.organization_id WHERE ((`organizations_users`.user_id = 2953))
SQL (0.1ms) BEGIN
Organization Load (1.1ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`name`) = BINARY 'asdfa') LIMIT 1
Organization Load (2.2ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`hq_url`) = BINARY '12341234') LIMIT 1
QuickFact Columns (1.3ms) SHOW FIELDS FROM `quick_facts`
SQL (2.2ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
SQL (0.1ms) ROLLBACK
SQL (3.1ms) BEGIN
CACHE (0.0ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`name`) = BINARY 'asdfa') LIMIT 1
CACHE (0.0ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`hq_url`) = BINARY '12341234') LIMIT 1
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
SQL (0.1ms) ROLLBACK
CACHE (0.0ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`name`) = BINARY 'asdfa') LIMIT 1
CACHE (0.0ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`hq_url`) = BINARY '12341234') LIMIT 1
SQL (0.1ms) BEGIN
CACHE (0.0ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`name`) = BINARY 'asdfa') LIMIT 1
CACHE (0.0ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`hq_url`) = BINARY '12341234') LIMIT 1
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
SQL (0.1ms) ROLLBACK
SQL (0.1ms) BEGIN
CACHE (0.0ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`name`) = BINARY 'asdfa') LIMIT 1
CACHE (0.0ms) SELECT `organizations`.id FROM `organizations` WHERE (LOWER(`organizations`.`hq_url`) = BINARY '12341234') LIMIT 1
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
SQL (0.1ms) ROLLBACK
Rendering template within layouts/application
Rendering organizations/new
Rendered organizations/_form (4.2ms)
Rendered layouts/_head (2.7ms)
SQL (0.7ms) SELECT count(*) AS count_all FROM `organizations` INNER JOIN `organizations_users` ON `organizations`.id = `organizations_users`.organization_id WHERE ((`organizations_users`.user_id = 2953))
Rendered layouts/_login_status_new (2.1ms)
Rendered layouts/_header_new (2.9ms)
Rendered layouts/_need_login (0.2ms)
Rendered layouts/_already_have_tooltip (0.1ms)
Completed in 227923ms (View: 34, DB: 29) | 200 OK [http://localhost/organizations]
SQL (0.1ms) SET NAMES 'utf8'
SQL (0.1ms) SET NAMES 'utf8'
SQL (0.1ms) SET SQL_AUTO_IS_NULL=0
Processing DynamicStylesheetsController#image_css to css (for 127.0.0.1 at 2011-10-12 15:46:50) [GET]
Parameters: {"format"=>"css", "action"=>"image_css", "controller"=>"dynamic_stylesheets"}
At a guess, these lines:
SQL (2.2ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
CACHE (0.0ms) SELECT count(*) AS count_all FROM `quick_facts` WHERE (`quick_facts`.organization_id = NULL)
SQL (0.1ms) ROLLBACK
.. mean that you have a uniqueness validation that's failing because the null value is "taken".