barsoom/traco

Rails 6.0.3: Gem breaks rails console

robbevp opened this issue · 4 comments

This is probably an issue on my end, but I can't seem to figure it out.

Because I included translates in my model, everything I try to do with it in the rails console throws an error like this:

Traceback (most recent call last):
        3: from (irb):3
        2: from app/models/food.rb:23:in `<main>'
        1: from app/models/food.rb:24:in `<class:Food>'
NoMethodError (undefined method `translates' for #<Class:0x00007fbec6ad2938>)
Did you mean?  transaction

I've included it in my model like this:

23 class Food < ApplicationRecord
24   translates :question, fallback: :default

I've added no other configuration for the gem in my application. While using the application everything works as you would expect.

I'm using Rails 6.0.3 with Traco 5.0. Any help is very welcome.

Thanks for including the Rails version number!

I edited the title to include it.

Hi @robbevp!

That's very strange. Tests pass on Rails 6, so it should work in general (and seems to work for you in the web app, but breaks consoles, if I understand you correctly).

If you still see this issue, could you help us debug it by replacing the translates … line in your record with a line like Traco, just to verify that Traco loads at all? If not, what does the Traco line in your Gemfile look like exactly?

What's supposed to happen is that Rails/RubyGems loads https://github.com/barsoom/traco/blob/master/lib/traco.rb, which loads https://github.com/barsoom/traco/blob/master/lib/traco/translates.rb, which should add the translates class method to everything that inherits from ActiveRecord::Base.

@henrik This was for a small one-off project, so I have not looked at this in a while. (Only updating dependencies)
I can't seem to replicate this anymore, even when checking out a commit from around the time of this issue.

This can be closed as far as i'm concerned

Thank you for checking, @robbevp! Closing :)