-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
POST and PUT request params get dropped (rails 4, angularjs) #417
Comments
Fyi, I upgraded https://github.com/dblock/grape-on-rails to Rails 4.0 rc1 without issues, everything works as expected. Looking. |
I ran the app in https://github.com/hc5duke/grape_on_rails4 and I can do |
Thanks for taking a look. I've done a little more poking around and narrowed it down to this: Rails 3, working:
Rails 4, not working:
|
Rails forgets to rewind the input it reads. It's probably by design, I don't think I want to track that one down. Fixed in 37fe09a and also added a working sample with a test in dblock/grape-on-rails@b721e42. This can be monkey patched like this if you're on a stable version of Grape (config/initializers/grape.rb). module Grape
module Middleware
class Formatter < Base
alias_method :_read_body_input, :read_body_input
def read_body_input
env['rack.input'].rewind if env['rack.input']
_read_body_input
end
end
end
end |
Sweet. Thanks for the quick turnaround on this. |
Opened rails/rails#10840, maybe someone on the Rails team will comment. |
Works fine for me! |
This is likely the same issue from this google groups thread. I created two small projects to demonstrate the issue:
Both projects are using
grape
at 948696f onmaster
with identical gems whenever possible. -rails3 is at v3.2.13, and -rails4 is at v4.0.0.rc1.In both 3 and 4, jQuery requests are handled correctly, but when angular sends POST or PUT requests, the request is received by grape without any params (unless you hard-code it as part of the url), as evidenced by results fields. It is possible that the issue is angularjs - but given that the requests are nearly identical between what angularjs is sending between these two projects, it seems more likely that something in grape gem + rails 4 interaction is the cause of this bug.
The text was updated successfully, but these errors were encountered: