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

using attribute_methods in combination with select raises MissingAttributeError #563

Open
jnylen opened this issue Apr 11, 2022 · 1 comment
Labels

Comments

@jnylen
Copy link

jnylen commented Apr 11, 2022

Context

Using Rails 6.1 and combining the attribute_methods plugin from master with Model.select(:name) when you have other fields that are translateable, it would raise ActiveRecord::MissingAttributeError as you are not including those fields.

I.e.

Mobility.configure do
  plugins do
    backend :jsonb
    ransack
    dirty

    active_record

    fallbacks
    reader
    writer
    query
    cache
    presence
    default
    attribute_methods
    locale_accessors
  end
end

class Model < ApplicationRecord
   extend Mobility
   translates(:name, :description)
end

> Model.select(:name)
ActiveRecord::MissingAttributes => :description

Expected Behavior

It should only depend on selected/valid fields

Actual Behavior

ActiveRecord::MissingAttributeError is being raised.

Possible Fix

Surströmming and disabling attribute_methods for now.

@shioyama shioyama added the bug label May 2, 2022
@shioyama
Copy link
Owner

shioyama commented May 2, 2022

Hmm ok this seems like a genuine bug. I'll try to have a look, honestly that plugin is kinda weird and I haven't done more than minimal maintenance on it.

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

No branches or pull requests

2 participants