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

Readme: Serializer Classes Not Automatically Reloaded #111

Open
dmin opened this issue Dec 5, 2014 · 1 comment
Open

Readme: Serializer Classes Not Automatically Reloaded #111

dmin opened this issue Dec 5, 2014 · 1 comment

Comments

@dmin
Copy link

dmin commented Dec 5, 2014

Awesome library!

This is only a possible issue with the readme, in the Getting Started section it gives instructions to add the following code to an initializer:

Dir[Rails.root.join('app/serializers/**/*.rb')].each do |path|
  require path
end

If you are using Rails' standard autoloading/reloading features in development the above initializer will prevent rails from reloading your serializer classes after you change them because of the explicit require statements.

Something more along the lines of

config.autoload_paths += ["#{config.root}/app/serializers"]

in config/application.rb should allow for your serializer classes to be automatically reloaded by rails in development. (this assumes that you have a serializer saved as /app/serializers/model_name_serializer.rb, and the corresponding class in that file named ModelNameSerializer)

@chourobin
Copy link

I thought Rails already includes everything in the app/ directory for autoloading? I gave your suggestion a shot but unfortunately, it would lazy load the first serializer used in the app and not load the other ones leading to an error. I would be interested to see if anyone faced similar issues trying to get RestPack Serializers to play nice with Rails autoloading.

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

No branches or pull requests

2 participants