-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't create Taxonomy with Spree 4.4 #6
Comments
I can immediately confirm this as I had the same problem on a new Spree (5.alpha) project. The presence validator is not an "issue" by itself, actually it is a feature compared to spree_globalize, which didn't have validations on translations models - which means you basically can have invalid data in the DB which can cause all sort of issues. Ideally the uniqueness validation should also be added to translations yeah, iirc it was a little too complicated at this point though (translations table doesn't directly have parent_id/taxonomy_id so it'd have to go through a join - custom validator). |
@Kulgar okay so I figured out what's going on. Another after_save hook (sync_taxonomy_name) was added in 4.4.x to Taxon, which triggers after Taxonomy is created and before Taxonomy translations are created in DB. Although possibly mobility can be improved for such situation to not be a problem, avoiding this hook on create (when it is not necessary anyway) fixes it. I fixed this in mrbrdo/spree@45e1679 on my 4_4_fixes branch of spree (which is actually 5.alpha). |
@mrbrdo : thanks for the investigation! Weird, as I did solve / fix the bug by just commenting this line in spree mobility decorator:
I didn't have to patch Spree 4.4 in any way to make it work... |
Yeah, but now you don't have validation on the name. Which means you can save a Taxon with an empty name, but that shouldn't be allowed. |
ok, understood, but patching Spree isn't an option for me right now :-) |
@Kulgar spree just merged the fix into main branch: |
nice, thanks @mrbrdo |
Hello again :-)
I faced a new issue today: I'm no longer able to create new taxonomies.
After some digging, I found that the culprit is that line :
In the taxon_decorator.rb file.
Indeed, when we create a new Taxonomy, it automatically creates a new taxon :
In Spree 4.4, the Taxon name validation is this:
I don't really have time to investigate more... but, right now, deactivating the validates in the decorator fixes my problem.
Do you have any idea on a possible fix?
Thx!
The text was updated successfully, but these errors were encountered: