Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 09 03:48

    ddnexus on dev

    version 3.7.1 Merge branch 'dev' (compare)

  • Dec 09 03:48

    ddnexus on master

    Type cast pagy_arel_count value… version 3.7.1 Merge branch 'dev' (compare)

  • Dec 09 03:47

    ddnexus on 3.7.1

    version 3.7.1 Merge branch 'dev' (compare)

  • Dec 09 03:40
    ddnexus commented #207
  • Dec 09 03:40

    ddnexus on dev

    Type cast pagy_arel_count value… (compare)

  • Dec 09 03:40
    ddnexus closed #207
  • Dec 09 03:39
    ddnexus edited #207
  • Dec 05 22:21
    codecov[bot] commented #207
  • Dec 05 22:01
    rainerborene opened #207
  • Nov 20 00:40
    ddnexus commented #206
  • Nov 20 00:40
    ddnexus closed #206
  • Nov 20 00:39
    ddnexus commented #206
  • Nov 20 00:32
    nikolaokonesh opened #206
  • Nov 19 14:21
    ddnexus commented #205
  • Nov 19 11:55
    dcalixto closed #205
  • Nov 19 11:55
    dcalixto commented #205
  • Nov 18 12:01
    ddnexus commented #205
  • Nov 17 21:49
    dcalixto opened #205
  • Nov 17 21:43
    dcalixto closed #204
  • Nov 17 21:43
    dcalixto edited #204
KirtimanStha
@KirtimanStha
haha.... ok... thank you soo much for your time..
Domizio Demichelis
@ddnexus
btw, the concept is use the metadata to serve the pagination data you need and use it in the frontend
KirtimanStha
@KirtimanStha
yes i understood it very well.... but for some reason i am not able to implement in frontend
Domizio Demichelis
@ddnexus
ahhh... so you are getting it served and available in the frontend, right?
KirtimanStha
@KirtimanStha
yes
Domizio Demichelis
@ddnexus
that's good, and that means that you are handling the pagy part perfectly
for vue, I would ask in some vue forum
KirtimanStha
@KirtimanStha
thank you
can you suggest me some vue forum??
Domizio Demichelis
@ddnexus
my suggestion is: don't mess them up with explaining pagy: just explain that you have some json data containing a link and you nee to use that link
I don't use vue, and I would google it as well :)
KirtimanStha
@KirtimanStha
ok thanks
Domizio Demichelis
@ddnexus
BTW, I like vue a lot... I just never had the occasion to do any project using it
Vincent Voyer
@vvo

Hi there, coming from will_paginate I am looking to specify controller/action like they do here: https://github.com/mislav/will_paginate/wiki/API-documentation#view-template-helpers.
Example:

  <%= will_paginate @feed_items,
                    params: { controller: :static_pages, action: :home } %>

This basically allows to generate links such as /?p=1 while the browser url is at /microposts. Thanks!

Domizio Demichelis
@ddnexus
@vvo not sure I understand what you need... controller/action... arent't you paginating already in a action?
ah... I think I've got it
you mean you want to generate a pagination link pointing to an arbitrary controller/action different than the one you are in
Vincent Voyer
@vvo
So I have a homepage displaying a user feed which is a list of micro blog post basically with pagy, it works well for this part. There's a form on the homepage that allows to create a new micro blog post (micropost controller). Now when the form is success, I redirect to homepage again. But when there's an error I stay on /micropost and just render the homepage again with the form errors, but then the feed pagination is broken because it uses /micropost urls instead of homepage urls.

you mean you want to generate a pagination link pointing to an arbitrary controller/action different than the one you are in

yes!

I believe this might be kinda anti pattern to try to solve, I am new to Rails. I render the homepage in the micropost controller so I can keep the form errors showing (vs doing a redirect I would lose them). I guess this could be better answered via an AJAX form instead
Domizio Demichelis
@ddnexus
indeed it doesn't look any useful to add a /?p=1. If you just generate a link without the page, pagy will use p=1
just go to the page, and paginate its output there
Vincent Voyer
@vvo
not sure to get it eheh
Domizio Demichelis
@ddnexus
ok, so just generate a link for the home page in your case
Vincent Voyer
@vvo
Yes this is what I am looking to do, tell pagy to generate the link not with /controller?p=1 but with /?p=1 but can't find a way to do so
Domizio Demichelis
@ddnexus
when you render the home page, in the show action, you just do @pagy, @records = pagy(your_scope)
you know how to likk to a controller/action, right?
pagy does not need to get involved to generate the link: you can use the rails link_to for that
and no need to tell any page, since without any page the default is 1
so in one case you generate the link as "/controller" and in the other case you generate the link as "/", by using the regular link_to helper
in the show actions of both controllers you paginate your collection with pagy
the super standard way will take care of reading the page param and generating the page links correctly
Domizio Demichelis
@ddnexus
wait... I have a doubt now: do you mean that you want all the links in the pagination bar to get modified with a different controller?
I don't see a use case for it, but if it is really what you need, then you can simply do something like pagy(your_collection, params:{controller: :static_pages, action: :home}) exactly as you do with will_paginate
Domizio Demichelis
@ddnexus
re-reading what you explained... you mentioned "urls" plural, so you probably mean all the links in the bar... if it's that I think I finally got it :)
Vincent Voyer
@vvo
You definitely got it, let me try your suggestion now
I tried @pagy, @feed_items = pagy(current_user.feed, params: { controller: :static_pages, action: :home }) but all it does is generate this kind of url: http://localhost:3000/microposts?controller=static_pages&action=home&page=1 instead of the one that would work: http://localhost:3000/?page=1 ). I am following a rails tutorial that was using will_paginate. But I think the whole tutorial about having a form and data list on the home page that belongs to another controller is kinda broken pattern and that's why I am struggling here :D
The form on the homepage even when in error should not be loading a url like /microposts, does not make sense because this url once reloaded does nothing
Domizio Demichelis
@ddnexus
You are right about the params... pagy does not use any rails helper, so have no concept of controller or action... in order to make it work, you should override the pagy_url_for making it use the rails helpers, which are slower
BTW, if you can avoid that way, then there will be no need to do that combersome stuff
Vincent Voyer
@vvo
yes this already felt weird when reading the tutorial to have this kind of url patterns/flows where you even have to get the feed of data from one controller or the other depending on success/error of the mainpage form.
Thanks for all your answers btw, amazing commitment to your open source work!
Domizio Demichelis
@ddnexus
thanks for the thanks ;)
Vincent Voyer
@vvo
I solved my original question: there's not really a way to achieve what will_paginate was doing (but with pagy_url_for). But at the same time, this is a weird pattern/need that should be solved in another way.
Domizio Demichelis
@ddnexus
as I said there is a quite simple way to do it, overriding the pagy_url_for method... it should be quite simple, but that method is about 20 times faster than rails url_for
Vincent Voyer
@vvo
Yes indeed, since this is just a tutorial I will skip it and when implementing my own projects I will chose a different strategy, thx!
Archonic
@archonic
Hi folks. I'm translating my app and I've found that pagination isn't translating. I've looked at the docs and set the locales available in the initializer and set pagy_locale in my application controller. I'm using the pagy_bootstrap_nav helper to display the pagy nav. Is that inherently incompatible with translation?
Domizio Demichelis
@ddnexus
i18n works with all the helpers, hence you have probably some misconfiguration
I guess you have read the i18n doc
btw it is @pagy_locale not just pagy_locale