rails-api / active_model_serializers

ActiveModel::Serializer implementation and Rails hooks
MIT License
5.32k stars 1.39k forks source link

v. 0.9.5 not working with rails v6 and zeitwerk autoloading mode #2431

Open hadiS opened 2 years ago

hadiS commented 2 years ago

Hi! Does anybody else have problems with active model serialisers v. 0.9.5 with zeitwerk autoloading mode in rails 6?

My serializers are being ignored completely. No errors or warnings are being thrown. But whenever I add them manually in my controllers like

render json: @user, serializer: UserSerializer

it works fine! Switching autoloading to classic mode works too.

When I downgrade ams to v. 0.8.5 it works too, hence serializers work fine again and are being found automatically in rails 6 with zeitwerk mode.

bf4 commented 2 years ago

0.8, 0.9, and 0.10 are more or less mutually incompatible. If you're on 0.9, I do not recommend trying to downgrade.

I'm happy to support a PR to make zeitwerk mode work.

myousry22 commented 1 year ago

@bf4 where is the solution am using ams v= 0.10.13?

bf4 commented 1 year ago

Need a detailed bug report to have any hope of solving it

favechua commented 1 year ago

@bf4 Having the same issue with rails 6 zeitwerk loader (using v0.10.13). It will return error like:

NoMethodError:
  undefined method `model_name' for MyClass
  Did you mean?  module_parent
bf4 commented 1 year ago

Doesn't sound like a zeitwerk related issue to me, but can't tell without a detailed bug report @favechua