How to Implement Pagination in Ruby on Rails (Without Gems)

  Рет қаралды 7,279

Jesus Castello

Jesus Castello

Күн бұрын

Пікірлер: 24
@sr0409rr
@sr0409rr 3 жыл бұрын
Thanks, I was looking for a gem to get this done and then I found this tutorial :)
@UlfredTag
@UlfredTag 2 жыл бұрын
Thank you so much for this! The perfect solution to my problem
@Encoreencore
@Encoreencore 2 жыл бұрын
Amazing tutorial. Thanks Jesus!
@JesusCastello
@JesusCastello Жыл бұрын
Glad you enjoyed it!
@btechstuff
@btechstuff 4 жыл бұрын
This was very informative, thank you friend.
@JesusCastello
@JesusCastello 4 жыл бұрын
Glad it was helpful! :)
@CristianMolina
@CristianMolina 3 жыл бұрын
Great , thx! Do you have something showing how to move the pagination stuff to a controller concern? Regards!
@wmcraver
@wmcraver 5 жыл бұрын
It seem like it would be pretty easy to add some logic to calculate the max number of possible pages based on the total number of items (total books / books_per_page and use the ceil command). Then Add some ERB logic so that the last page doesn't show on page 0 and so that next page doesn't show on the max page, yeah?
@detrix42
@detrix42 4 жыл бұрын
Thank you very much. Yes, pagination is not that hard. I needed this video to be reminded of the offset method.
@JesusCastello
@JesusCastello 4 жыл бұрын
Glad it was helpful! :)
@SamNeter
@SamNeter 3 жыл бұрын
A question - how can you remove 'Last Page' and 'Next Page' on pages where there is no last page (the first page) and no next page (on the final page of results) - so it detects when there are no further books to paginate so it removes the option? Hope that makes sense!
@JesusCastello
@JesusCastello 3 жыл бұрын
That is a great question Sam! You'll need to use some logic statements to solve this. In other words, you need if statements to check if the next page would have more books on it or not, if it doesn't then you skip the ERB (or HAML, Slim, etc.) code for the "Next Page" section.
@EfstathiosStivaros
@EfstathiosStivaros 5 жыл бұрын
Really enjoyed this, thanks. A lot of the time we reach for gems which do basic functions and add foreign code into our apps which we don't need. I know I'm definitely guilty.
@sunn19m
@sunn19m 3 жыл бұрын
This is a great tutorial video! Thank you! Also, do you have a video on setting up those individual book/images as links? I could probably find it elsewhere; but I like the way you have your page set up! Thank you!
@JesusCastello
@JesusCastello 3 жыл бұрын
For each book you can use the link_to method. api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
@sunn19m
@sunn19m 3 жыл бұрын
@@JesusCastello Thank you!
@rubyhat
@rubyhat 4 жыл бұрын
Thanks!
@jackblack2615
@jackblack2615 5 жыл бұрын
Thank you
@devgalileu
@devgalileu 4 жыл бұрын
Awesome, a great tutorial, totally unecessary use gems to achieve this.
@JesusCastello
@JesusCastello 4 жыл бұрын
Agreed! :)
@bryanperez4148
@bryanperez4148 4 жыл бұрын
you're awesome
@JesusCastello
@JesusCastello 4 жыл бұрын
Thanks! :)
@ShashiKumar-jt2xk
@ShashiKumar-jt2xk 4 жыл бұрын
please add search option
@JesusCastello
@JesusCastello 4 жыл бұрын
You can find it here: kzbin.info/www/bejne/bYOzo2tpe754oac
How to Implement a Search Feature in Ruby on Rails
16:22
Jesus Castello
Рет қаралды 20 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
How to Migrate Data to Sanity Using APIs | Hackathon | Day3
16:18
Subhan Kaladi
Рет қаралды 2,9 М.
Dynamic Select Fields in Rails using Hotwire
19:46
GoRails
Рет қаралды 25 М.
What Classes Should You Create in Your Ruby Programs?
18:30
Jesus Castello
Рет қаралды 1,6 М.
Rails Methods: ActiveRecord#Pluck (How it Works & When to Use It)
10:19
Ruby on Rails Routing - Part 1
25:13
webcrunch
Рет қаралды 9 М.
The Only Database Abstraction You Need | Prime Reacts
21:42
ThePrimeTime
Рет қаралды 234 М.
Rails scaffold deepdive
53:50
CJ Avilla (cjav_dev)
Рет қаралды 5 М.
Understanding Rails Params & How to Use Them
9:40
Jesus Castello
Рет қаралды 9 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН