Has anyone else come across this? I'm writing a Rails API in Rails 5 ( 5.0.0.beta2
), and have included the responder
gem so as to be able to use respond_with
, and put respond_to :json
in the controller, but no matter what I pass to respond_with
(eg respond_with @collection
), the response is always blank. Anyone know why this might happen?
responders 2.1.2
包括对ActionController::API
的修复,更新您的应用
have you tried responding in the controller with something like:
render :json => { data: "Success!" }
or if you're in a respond_to block, something like:
format.json { render json: "Success!" }
https://stackoverflow.com/a/46554377/8518019
steps: 1. add to gemfile gem 'responder', '~> 2.0'
rails generate responder:install
rails generate scaffold ....
I suggest running rake db:drop. db:create then rake db:migrate (I am pretty early on in my app so my database wasnt something i was concerned about deleting and re-creating)
It worked for me after I included the gemfiles before i created the scaffold hope this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.