-
Notifications
You must be signed in to change notification settings - Fork 188
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
Avoid saving new translations that are empty, remove existing empty translations. #14
base: master
Are you sure you want to change the base?
Conversation
… unsaved translations from params and b) mark empty saved translations for deletion.
Devise's Session does not translate, which led to an error in the original implementation.
Hi Sebastian, I like your Idea but im not so sure if this is the right way, cause with your code every ActiveRecord update/create triggers the before filter FilterEmptyTranslations. Now just imagine some guy has also an entry called "translations_attributes" but has not the structure form activeadmin-globalize3. Then it will delete the entries and the guy might be really confused ;) I like to have the method centralized, but I think it should be configurable where the filter should trigger. |
oh, I didn't see that commit. Great! in this case I like your implementation :) |
I added this later. But you are right, adding the filter to ActionController::Base is probably not the best of all options. I will look into adding the filter automatically only to classes which do |
use all? instead of mapping to boolean and checking for include? use blank? instead of empty? on translated attributes
… new translations that are empty, remove existing empty translations
… new translations that are empty, remove existing empty translations
This works pretty well. Any reason for this not being merged at this point? |
I found at least one reason: I do not know out of my head how exactly the Rails However, this could be fixed easily; all that is required is parsing the |
Activeadmin-globalize3 renders inputs for all possible translations. Consequently,
params
will contain translations for all attributes - even empty ones - and many empty translation records will be created.This feature registers a
before_filter
inActionController::Base
that willparams
before creating any empty recordsparams
for deletionSee #10, most credits go to codingluke and fabn, thanks!