質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

ページネーション

Webアプリケーションにおいて、1ページに収まらないコンテンツを、各ページへのリンクを並べてアクセスしやすくする手法をページネーションと呼びます。

Q&A

0回答

1397閲覧

ArgumentError in Users#index pagenate

tuyosip

総合スコア12

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

ページネーション

Webアプリケーションにおいて、1ページに収まらないコンテンツを、各ページへのリンクを並べてアクセスしやすくする手法をページネーションと呼びます。

0グッド

0クリップ

投稿2019/11/22 14:57

railsチュートリアルの10章の10.3.3 ページネーションで

ruby

1<% provide(:title, 'All users') %> 2<h1>All users</h1> 3 4<%= will_paginate %> 5 6<ul class="users"> 7 <% @users.each do |user| %> 8 <li> 9 <%= gravatar_for user, size: 50 %> 10 <%= link_to user.name, user %> 11 </li> 12 <% end %> 13</ul> 14 15<%= will_paginate %> 16

index.html.erbに<%= will_paginate %>を入れてindexアクションも

ruby

1def index 2 @users = User.paginate(page: params[:page]) 3 end

と書き換えたのですが
ArgumentError in Users#index
wrong number of arguments (given 0, expected 1)と表示され
<%= will_paginate %>に原因があるとされどうすればいいか分かりません。
またrails consoleでUser.paginate(page: 1)と打つと User Load (3.3ms) SELECT "users".* FROM "users" LIMIT ? OFFSET ? [["LIMIT", 11], ["OFFSET", 0]]
ArgumentError: wrong number of arguments (given 0, expected 1)とエラーが表示されました

gemfileは以下です

ruby

1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.4.9' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 5.2.3' 8gem 'bootstrap-sass', '3.3.7' 9gem 'bcrypt', '3.1.12' 10gem 'faker', '1.9.1' 11gem 'will_paginate', '3.1.6' 12gem 'bootstrap-will_paginate', '1.0.0' 13gem 'jquery-rails' 14gem 'jquery-ui-rails' 15 16# Use sqlite3 as the database for Active Record 17gem 'sqlite3' 18# Use Puma as the app server 19gem 'puma', '~> 3.11' 20# Use SCSS for stylesheets 21gem 'sass-rails', '~> 5.0' 22# Use Uglifier as compressor for JavaScript assets 23gem 'uglifier', '>= 1.3.0' 24# See https://github.com/rails/execjs#readme for more supported runtimes 25gem 'duktape' 26# Use CoffeeScript for .coffee assets and views 27gem 'coffee-rails', '~> 4.2' 28# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 29gem 'turbolinks', '~> 5' 30# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 31gem 'jbuilder', '~> 2.5' 32# Use Redis adapter to run Action Cable in production 33# gem 'redis', '~> 4.0' 34# Use ActiveModel has_secure_password 35# gem 'bcrypt', '~> 3.1.7' 36 37# Use ActiveStorage variant 38# gem 'mini_magick', '~> 4.8' 39 40# Use Capistrano for deployment 41# gem 'capistrano-rails', group: :development 42 43# Reduces boot times through caching; required in config/boot.rb 44gem 'bootsnap', '>= 1.1.0', require: false 45 46group :development, :test do 47 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 48 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 49end 50 51group :development do 52 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 53 gem 'web-console', '>= 3.3.0' 54end 55 56group :test do 57 # Adds support for Capybara system testing and selenium driver 58 gem 'capybara', '>= 2.15' 59 gem 'selenium-webdriver' 60 # Easy installation and use of chromedriver to run system tests with Chrome 61 gem 'chromedriver-helper' 62end 63 64# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 65gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 66

だれかわかる方いませんか?

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問