Closed cjmarkham closed 7 years ago
Any particular reason you're include Rails.application.routes.url_helpers
?
Without it I get errors on all routes used within the serializer:
undefined local variable or method `api_foo_path' for #
Just a heads up. It works fine in development but not in production. In an attempt to replicate the error on development I set some of the configs to the same as production. Turns out when I set config.eager_load
from false to true, it breaks with the above error. With it set to true I cannot use any routes in serializers (undefined local variable or method `api_foo_path') and get the controller error message using links.
Might be a load order thing... and we need to add reload routes before including it
B mobile phone
On Mar 21, 2017, at 8:52 PM, Carl Markham notifications@github.com wrote:
Just a heads up. It works fine in development but not in production. In an attempt to replicate the error on development I set some of the configs to the same as production. Turns out when I set config.eager_load from false to true, it breaks with the above error. With it set to true I cannot use any routes in serializers (undefined local variable or method `api_foo_path') and get the controller error message using links.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
I'm going to close this for now as it appears to be a config issue. I created a new rails app and followed the same steps but couldn't reproduce.
If I find the issue I will come back to let you know.
Expected behavior vs actual behavior
Expected links to be returned Actual:
Steps to reproduce
Set adapter to json_api and add relationship links to serializer
Environment
ActiveModelSerializers Version (commit ref if not on tag):
Output of
ruby -e "puts RUBY_DESCRIPTION"
:Backtrace
Additonal helpful information
Controller method
Serializer: