You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When current path contains path params, kerosene produces urls with duplicated param keys in a query.
e.g. I have a path with brand_id param: /:brand_id/products/.
When I pass the whole params map to Repo.paginate, it generates incorrect page links, such as: /asus/products?brand_id=asus&page=2.
One way to resolve it is to drop those path keys from params when passing it to Repo.paginate:
But it makes the code more brittle and difficult to update later, because we'll need to keep track of such params.
I looked into source code and I understand why it's happening.
The question is - Is there a better way to avoid such issues?
Maybe we could introduce some option to drop such keys automatically.
use Kerosene, exclude_params: ~w(locale brand_id)
I'm not particularly fond of this solution, because it's global option that applies to all Repo.paginate calls. But it could work fine for global path params, such as locale.
What do you think?
The text was updated successfully, but these errors were encountered:
When current path contains path params, kerosene produces urls with duplicated param keys in a query.
e.g. I have a path with brand_id param:
/:brand_id/products/
.When I pass the whole
params
map toRepo.paginate
, it generates incorrect page links, such as:/asus/products?brand_id=asus&page=2
.One way to resolve it is to drop those path keys from params when passing it to
Repo.paginate
:But it makes the code more brittle and difficult to update later, because we'll need to keep track of such params.
I looked into source code and I understand why it's happening.
The question is - Is there a better way to avoid such issues?
Maybe we could introduce some option to drop such keys automatically.
I'm not particularly fond of this solution, because it's global option that applies to all
Repo.paginate
calls. But it could work fine for global path params, such aslocale
.What do you think?
The text was updated successfully, but these errors were encountered: