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

Tolk with protected_attributes gem #68

Open
ilkerinanc opened this issue Jul 6, 2014 · 4 comments
Open

Tolk with protected_attributes gem #68

ilkerinanc opened this issue Jul 6, 2014 · 4 comments

Comments

@ilkerinanc
Copy link

Hi,

I'm using Rails 4 and Ruby 2 and I'm also using protected_attributes gem in my Gemfile. That causes me the following error upon running rake tolk:sync :

NoMethodError: undefined method `to_sym' for nil:NilClass
/Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/tolk-1.5.1/lib/tolk/sync.rb:14:in `load_translations'
/Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/tolk-1.5.1/lib/tolk/sync.rb:9:in `sync!'
/Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/tolk-1.5.1/lib/tasks/tolk_tasks.rake:19:in `block (2 levels) in <top (required)>'
/Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/bugsnag-2.1.0/lib/bugsnag/rake.rb:34:in `block in bugsnag_define_task'
/Users/ilker/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `eval'
/Users/ilker/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `<main>'

When I further dig down and run the Tolk::Locale.sync! in console I get the following:

Tolk::Locale Load (1.2ms)  SELECT "tolk_locales".* FROM "tolk_locales" WHERE "tolk_locales"."name" = 'en' LIMIT 1
WARNING: Can't mass-assign protected attributes for Tolk::Locale: name

   (0.2ms)  BEGIN
  Tolk::Locale Exists (0.4ms)  SELECT 1 AS one FROM "tolk_locales" WHERE "tolk_locales"."name" IS NULL LIMIT 1
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
   (0.2ms)  ROLLBACK
NoMethodError: undefined method `to_sym' for nil:NilClass
    from /Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/tolk-1.5.1/lib/tolk/sync.rb:14:in `load_translations'
    from /Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/tolk-1.5.1/lib/tolk/sync.rb:9:in `sync!'
    from (irb):1
    from /Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.1/lib/rails/commands/console.rb:90:in `start'
    from /Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.1/lib/rails/commands/console.rb:9:in `start'
    from /Users/ilker/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.1/lib/rails/commands.rb:62:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Any ideas how to work around?

@ilkerinanc
Copy link
Author

Any ideas anyone?

@thomasdarde
Copy link
Member

I think an initializer would help, with a class overload and deprotecting some attributes of the gem. I'm not using protected_attributes with tolk

@dnrce
Copy link
Member

dnrce commented Oct 8, 2014

Hi @ilkerinanc, I am unable to reproduce this issue myself. Do you still experience the problem with Tolk 1.6.0?

@wpp
Copy link
Contributor

wpp commented May 5, 2015

I just ran into something similar, for a quick work-around I added the following to an initializer:

Tolk::Locale.send(:attr_accessible, :name)
Tolk::Phrase.send(:attr_accessible, :key)

["phrase", "phrase_id", "locale", "locale_id", "text", "previous_text", "primary_updated"].each do |attr|
  Tolk::Translation.send(:attr_accessible, attr)
end

I'm using

  • tolk (1.9.2)
  • protected_attributes (1.0.8)

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

No branches or pull requests

4 participants