-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
New 0.9 gem does not work out of the box with rails-api #600
Comments
I'm going to be doing work on |
I have the same issue, after update 175 tests fail :-( go back to 8.1 and all the tests pass: Below are some examples:
|
@ericbrooke if you happen to be able to isolate specific errors not related to rails-api, please open individual ones for them as well, thanks |
As a workaround, I found that just adding
to ApplicationController works. |
Yeah, I mentioned that in my initial post but I might have been rambling a bit too much for that to be clear. I've updated the post to so that people who look here for help should be able to see it easily 😄 |
I was having the same issue, @jspies's comment did help me! Shouldn't this be added to the project's README ? |
I could confirm this happens for Rails 5 with ActiveModelSerializer 0.9.4, and adding the include works. |
Sure, please send a PR and I'm happy to merge 😄 |
@MarcusSky @sbycrosz While generating scaffolds with a Rails 5 API project, I ran into the following issue on 0.9x which goes away on 0.10x - did you guys see the same issue? → rails g scaffold User
Running via Spring preloader in process 20090
invoke active_record
create db/migrate/20160911170034_create_users.rb
create app/models/user.rb
invoke test_unit
create test/models/user_test.rb
create test/fixtures/users.yml
invoke resource_route
route resources :users
create app/serializers/user_serializer.rb
invoke scaffold_controller
Could not find "api_controller.rb" in any of your source paths. Your current source paths are:
/Users/anuj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/active_model_serializers-0.9.5/lib/active_model/serializer/generators/serializer/templates |
I'm not sure whether this issue should be opened here or on the
rails-api
repository so let me know if this is the wrong place.Anyway,
active_model_serializers
does not work out of the box with a newrails-api
project, as the JSON responses aren't being overridden. I found this Stack Overflow question, which resulted in one solution: makingApplicationController
inherit fromActionController::Base
instead ofActionController::API
. With this I found out thatApplicationController
needsActionController::Serialization
for AMS to work.For those of you that are experiencing the issue, that means that you can just add the following to
ApplicationController
to work around the issue for now:If this behaviour is intended, shouldn't it be mentioned in the README?
I'm on Rails 4.1.5, rails-api 0.2.1 and active_model_serializers 0.9.0.
The text was updated successfully, but these errors were encountered: