https://github.com/sebouchu/ujs-pagination-app
Rails 7 + UJS + Kaminari
https://github.com/sebouchu/ujs-pagination-app
Last synced: over 1 year ago
JSON representation
Rails 7 + UJS + Kaminari
- Host: GitHub
- URL: https://github.com/sebouchu/ujs-pagination-app
- Owner: SebouChu
- Created: 2022-04-02T16:17:28.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-03T09:19:54.000Z (over 4 years ago)
- Last Synced: 2025-02-03T08:01:48.696Z (over 1 year ago)
- Language: Ruby
- Size: 54.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UJS Pagination App
Web application with articles, powered by Rails 7, Rails-UJS and Kaminari.
## Setup
- Clone this repo and move inside the project directory
- Run `bundle install`
- Run `yarn`
- Run `rails db:setup db:seed`
## Run
- Run `bin/dev`
## How does it work?
On the index, articles are paginated (8 per page). When we click on the "Load more" button, Rails-UJS catches the click, makes an AJAX request, still handled by `ArticlesController#index` but with `:js` format.
The `.js.erb` is processed by ERB then returned to Rails-UJS which executes the script. This script append the next articles to the list then updates or remove the « Load more » button.