-
Notifications
You must be signed in to change notification settings - Fork 634
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
Add columns managed by Globalize gem #602
Conversation
@ctran did you have to chance so far to have a look at it? |
Hey @ctran any chance that this PR could be reviewed and included in the next release? |
@drwl you seem to be actively working on this project. Can you have a look at the idea of this PR? I will rebase or restructure the code but only if there is a chance that it gets merged. |
Yes, we'll review and merge it. |
f2216b8
to
ab4cd2c
Compare
I rebase and restructured my added code a little bit. I'm still missing tests so this will be the next step. Is it the right approach to mock all methods from the |
ab4cd2c
to
0304c13
Compare
And I'm wondering whether this should be added to the Rubocop config:
wdyt? |
cb9405c
to
e42a3ac
Compare
I'm ok with that.
…On Tue, Dec 17, 2019, 23:48 Peter Gundel ***@***.***> wrote:
And I'm wondering whether this should be added to the Rubocop config:
Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
wdyt?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#602?email_source=notifications&email_token=AAAAD25AOFCDIPPA3DNPLSLQZHITPA5CNFSM4GYEX57KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHFHUNA#issuecomment-566917684>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAD2ZQPUJQWUJZKLKLS4TQZHITPANCNFSM4GYEX57A>
.
|
fd6f386
to
a20581f
Compare
Globalize hooks into the model and removes the translated columns from the `klass.columns`. This commit checks if globalize is hooked into the model and adds the necessary columns to the annotation array.
RSpec spec files can contain long blocks easily because of the outher describe methods. So this rule makes not too much sense for these files.
a20581f
to
19e3f24
Compare
@peterfication thanks for the PR! Gonna merge it in |
Why is it including the ID column as well? How do I disable globalize annotations? It looks confusing since the columns aren't really there. |
(1) Which ID column do you mean? It shouldn't include the one from globalize. If this is the case for your setup, it's a bug. Can you please share the versions you use (Rails, globalize, annotate_models)? (2) I'm very sorry for not picking a sensible default here. There should have been an option to enable it and the default should have been |
* Add columns managed by Globalize gem Globalize hooks into the model and removes the translated columns from the `klass.columns`. This commit checks if globalize is hooked into the model and adds the necessary columns to the annotation array. * Disable Rubocop Metrics/BlockLength for spec files RSpec spec files can contain long blocks easily because of the outher describe methods. So this rule makes not too much sense for these files.
I noticed the same behavior with table names that consist of multiple words (e.g. MyCar). Here a foreign_column_name = [
klass.translation_class.to_s
.gsub('::Translation', '').gsub('::', '_')
.downcase,
'_id'
].join.to_sym Globalize uses a different method to determine the foreign key. t.references table_name.sub(/^#{table_name_prefix}/, '').singularize, Defined here: https://github.com/globalize/globalize/blob/master/lib/globalize/active_record/migration.rb#L82 Perhaps a solution is to use a similar approach and use the table name of the class instead of the table name of the translation class. Alternative might be to use |
Globalize hooks into the model and removes the translated columns
from the
klass.columns
. This commit checks if globalize ishooked into the model and adds the necessary columns to the
annotation array.