Skip to content
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

Save empty translations #19

Open
itdxer opened this issue Dec 21, 2013 · 1 comment
Open

Save empty translations #19

itdxer opened this issue Dec 21, 2013 · 1 comment

Comments

@itdxer
Copy link

itdxer commented Dec 21, 2013

I have 4 translation in my site and 4 tabs for them. When I try create news for example with one translation and I save it it also create 3 another as "" strings.
How I can save just not void translations?

@fabn
Copy link

fabn commented Jun 6, 2014

I was looking for the same answer. I made a proof of concept with this before filter:

# Model is Article
before_filter only: [:create, :update] do
  params[:article][:translations_attributes].delete_if do |k,v|
    v.except('id', 'locale').all? { |_,v| v.blank? }
  end
end

While this works I don't like this solution. Another option would be to insert some javascript that does the same thing but client side disabling or removing empty elements from the submitted values.

@stefanoverna what do you think? I can try to work with javascript if it's fine for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants