Project

General

Profile

Actions

Bug #16389

closed

Can't create taxable e.g. domain object if I'm in context of specific organization or location

Added by Marek Hulán over 7 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Organizations and Locations
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Steps to reproduce:
1) make sure you have organization, e.g. org A
2) switch to org A in context selector
3) go to domain
4) create a domain assigned to org A, this might still work
5) try to create new one again assigned to org A (should be preselected since you're in its context), it will stuck on the creation form displaying no errors and you can find "Failed to save: Taxable taxonomies is invalid" in log (if you have at least info level enabled)

to reproduce from console

# make sure there's at least one Domain in Organization.first
Organization.current = Organization.first
d = Domain.new :organization_ids => [1]
d.valid? # => false
d.taxable_taxonomies # return invalid taxable taxonomies linked to other (existing!) domain

Cause:
It seems that default scope added by taxonomies registers ids of existing records which gets picked by https://github.com/rails/rails/blob/v4.2.7.1/activerecord/lib/active_record/scoping/named.rb#L39:AR when it creates associations. A workaround is to do Domain.unscoped.new


Related issues 5 (1 open4 closed)

Related to OpenSCAP - Bug #16229: Invalid Taxable taxonomies when creating policy through UIClosedShlomi Zadok08/22/2016Actions
Related to Foreman - Tracker #10022: Taxonomies related issuesNew04/05/2015

Actions
Related to Foreman - Bug #4731: Creating domain when organization selected produces duplicate key errorClosedJoseph Magen03/19/2014Actions
Related to Foreman - Bug #16463: with_taxonomy_scope returns all objects when no taxable ids availableClosedDaniel Lobato Garcia09/07/2016Actions
Has duplicate Foreman - Bug #16471: Cannot create Host Group: Taxable taxonomies is invalidDuplicate09/07/2016Actions
Actions

Also available in: Atom PDF