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

Globalize3 compatibility #41

Open
zdennis opened this issue Oct 5, 2012 · 3 comments
Open

Globalize3 compatibility #41

zdennis opened this issue Oct 5, 2012 · 3 comments

Comments

@zdennis
Copy link
Contributor

zdennis commented Oct 5, 2012

seed-fu doesn't currently work with globalize3 (if you try to seed models with translated attributes). I made a seed-fu-globalize3 gem which adds this functionality.

https://github.com/mhs/seed-fu-globalize3

I'm not in love with overriding a couple private methods of SeedFu::Seeder, but it got the job done. Any interest if I submit a patch to add this to seed-fu itself or would you like to leave this sort of thing as a separate gem?

If separate, what do you think about genericizing some of seeder functionality so other libraries could hook into it? (such as identifier valid column names and finding existing models).

WDYT?

@jonleighton
Copy link
Contributor

If separate, what do you think about genericizing some of seeder functionality so other libraries could hook into it? (such as identifier valid column names and finding existing models).

That sounds best to me if it's straightforward to do.

@yorkxin
Copy link

yorkxin commented Oct 17, 2016

@zdennis Hi, I just got a problem when using SeedFu with Globalize.

The problem is that SeedFu's constraints does only recognize column names, while Globalize requires developers to remove duplicated columns from model's table.

And unfortunately the gem you mentioned is not accessible anymore, so I can't confirm if the problem I got is the same as you had. So how did you solve this problem? Or did you submitted another patch to SeedFu? Or you just don't use SeedFu anymore?

Thanks!

@kronn
Copy link

kronn commented Jan 11, 2021

FWIW, I replicated the behaivour by using only ActiveRecord. I would prefer using seed-fu as before, but for one model I use the following work-around:

seed_fu_attr_array.each do |attrs|
  obj = App::ModelName.find_or_initialize_by(
    unique_attr: attrs.delete(:unique_attr)
  )
  obj.attributes = attrs
  obj.save!
end

Replace App::ModelName with your Model, :unique_attr with the previous constraint and seed_fu_attr_array with the list of attributes you would pass to the seed-Method.

HTH

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

4 participants