0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

rails g kaminari:views bootstrap4 でprivate method `themes' called for Kaminari::Generators::ViewsGenerator:Class (NoMethodError)というエラーが出る

Posted at

実行環境

  • Windows 10
  • Rails 6.0.3.6
  • Ruby 3.1.2

実践したこと

  • gem 'kaminari'を追加し、ページネーションを実装しようとしていました。
  • gem導入後、bootstrap用のビューテンプレートを作成しようとし、
    rails g kaminari:views bootstrap4のコマンドを実行したところ、
    タイトルのようなエラーが発生したため、解決のプロセスをまとめます。

エラー内容

ターミナル
% rails g kaminari:views bootstrap4
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:117:in `initialize': Invalid argument @ rb_sysopen - https://api.github.com/repos/amatsuda/kaminari_themes/git/refs/heads/master (Errno::EINVAL)
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:117:in `open'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:117:in `get_files_in_master'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:41:in `themes'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/kaminari-core-1.2.0/lib/generators/kaminari/views_generator.rb:30:in `copy_or_fetch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `block in invoke_all'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `map'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `invoke_all'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/group.rb:232:in `dispatch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/generators.rb:276:in `invoke'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/commands/generate/generate_command.rb:26:in `perform'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/command/base.rb:69:in `perform'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/command.rb:46:in `invoke'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.0.6/lib/rails/commands.rb:18:in `<main>'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.14.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.14.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from bin/rails:4:in `<main>'

解決方法

  • こちらの記事を参考にし、
    $ bundle exec rails g kaminari:views bootstrap4
    を実行しbundle経由で実行してあげると、導入することができました。
ターミナル
$ bundle exec rails g kaminari:views bootstrap4
      downloading app/views/kaminari/_first_page.html.haml from kaminari_themes...
   identical  app/views/kaminari/_first_page.html.haml
      downloading app/views/kaminari/_gap.html.haml from kaminari_themes...
   identical  app/views/kaminari/_gap.html.haml
      downloading app/views/kaminari/_last_page.html.haml from kaminari_themes...
   identical  app/views/kaminari/_last_page.html.haml
      downloading app/views/kaminari/_next_page.html.haml from kaminari_themes...
   identical  app/views/kaminari/_next_page.html.haml
      downloading app/views/kaminari/_page.html.haml from kaminari_themes...
   identical  app/views/kaminari/_page.html.haml
      downloading app/views/kaminari/_paginator.html.haml from kaminari_themes...
   identical  app/views/kaminari/_paginator.html.haml
      downloading app/views/kaminari/_prev_page.html.haml from kaminari_themes...
   identical  app/views/kaminari/_prev_page.html.haml

同じエラーに遭遇している方の参考になれば幸いです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?