Skip to content

Instantly share code, notes, and snippets.

@budnik
Created February 26, 2013 07:00
Show Gist options
  • Save budnik/5036536 to your computer and use it in GitHub Desktop.
Save budnik/5036536 to your computer and use it in GitHub Desktop.
rails WTF?
class FooBarController < ApplicationController
##
##This unscoping works:
def index
Campaign.unscoped do
Advertiser.unscoped do
@invoices = Invoice.all :include => [:campaign, :advertiser]
end
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @invoices }
end
end
##
## But this doesn't:
def index
Campaign.unscoped do
Advertiser.unscoped do
@invoices = Invoice.all :include => {:campaign => :advertiser}
end
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @invoices }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment