Created
December 6, 2012 21:04
-
-
Save barelyknown/4228392 to your computer and use it in GitHub Desktop.
Problem with hash conditions on joined tables in AR models of namespaced Rails engines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The namespaced table is not being determined in hash conditions. See below. | |
| module Carrier | |
| class Engine < ::Rails::Engine | |
| isolate_namespace Carrier | |
| end | |
| end | |
| module Carrier | |
| class Profile < ActiveRecord:: | |
| ... | |
| belongs_to :entity_type | |
| end | |
| end | |
| > Carrier::Profile.joins(:entity_type).where(entity_type: { name: "Shipper Only" }) | |
| SELECT "carrier_profiles".* FROM "carrier_profiles" INNER JOIN "carrier_entity_types" ON "carrier_entity_types"."id" = "carrier_profiles"."entity_type_id" WHERE "entity_type"."name" = 'Shipper Only' LIMIT 1 | |
| ActiveRecord::StatementInvalid: PG::Error: ERROR: missing FROM-clause entry for table "entity_type" | |
| > Carrier::Profile.joins(:entity_type).where("carrier_entity_types.name = ?", "Shipper Only").first | |
| SELECT "carrier_profiles".* FROM "carrier_profiles" INNER JOIN "carrier_entity_types" ON "carrier_entity_types"."id" = "carrier_profiles"."entity_type_id" WHERE (carrier_entity_types.name = 'Shipper Only') LIMIT 1 | |
| => #<Carrier::Profile id: ... > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment