-
Notifications
You must be signed in to change notification settings - Fork 148
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
Complex object serialization changed in 1.1.0 #158
Comments
Just checked my app with js-routes 1.1.0: > Routes.allReadApiV1InboxPath(1, {a: {b:2, c: 3}})
"/api/v1/inboxes/1/all_read?a%5Bb%5D=2&a%5Bc%5D=3"
> Routes.allReadApiV1InboxPath(1, {position: {latitude:50.34, longitude: 34.124}})
"/api/v1/inboxes/1/all_read?position%5Blatitude%5D=50.34&position%5Blongitude%5D=34.124" Can you provide you js-routes js file with compiled routes? |
I don't have it right now, I'll provide it later. Keep in mind that geolocation position is not a plain javascript object, can you try with the above code, i.e. navigator.geolocation.getCurrentPosition(function(position) {
Routes.allReadApiV1InboxPath(1, {position: position.coords})
}) Yesterday I spent some time debugging this and I think the key is the missing |
Hm, in this case if you have jquery, you can use: JsRoutes.setup do |config|
config.serializer = "jQuery.param"
end |
@fabn you should give us a more clear way to reproduce the issue. Maybe you pass a special type of JS object into route function that causes an issue. You need to figure it out by calling |
@bogdan https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition - it return some special type of object |
@le0pard Yes config serialize would solve my issue. I was wondering if it should be restored in gem code as default serializer. Otherwise this issue can be closed (maybe with a read me addition for that change) |
@fabn if we set it as default, js will get error for scripts, where not present jQuery. |
In the old code it was the default serializer if and only if jQuery is defined, imho it was a good approach. |
@fabn As I understand this PR allow to use ANY serializer, not only jQuery or build-in. So, if you need jQuery serializer - you can use it by adding one line in config |
Good to know, what incompatibility did you find? In any case I think that this issue can be closed then. |
Incompatibility is described here: #153 |
I'm using the javascript geolocation api in an application and I'm passing the position object as a GET param into a
Routes
call. When I upgraded to 1.1.0 my code stopped working and the position object is not passed anymore. This is likely due to #155.Here's my code (simplified)
On rails side using version 1.0.0 I have these parameters
In version 1.1.0 I get no params at all i.e. the generated url is
/points
.It would be nice to have back the old behavior.
Thanks.
The text was updated successfully, but these errors were encountered: