songtianlun
022eae3029
- Integrate Kaminari for pagination of users - Update users_controller to paginate users - Add pagination views for first, last, next, and previous pages - Seed database with example users for testing This commit introduces pagination to the user index view, allowing for better navigation through large sets of users. The Kaminari gem is utilized to handle pagination, improving the user experience by reducing load times and enhancing usability. Additionally, the seeding script has been updated to create multiple users for better testing of the pagination feature.
25 lines
907 B
Ruby
25 lines
907 B
Ruby
# This file should ensure the existence of records required to run the application in every environment (production,
|
|
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
|
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
|
#
|
|
# Example:
|
|
#
|
|
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
|
# MovieGenre.find_or_create_by!(name: genre_name)
|
|
# end
|
|
|
|
User.create!(name: "Example User",
|
|
email: "example@example.com",
|
|
password: "foobar",
|
|
password_confirmation: "foobar")
|
|
|
|
99.times do |n|
|
|
name = Faker::Name.name
|
|
email = "example-#{n+1}@railstutorial.org"
|
|
password = "password"
|
|
User.create!(name: name,
|
|
email: email,
|
|
password: password,
|
|
password_confirmation: password)
|
|
end
|