Rails で rails generate kaminari:views bootstrap3 が失敗するのを防ぐ方法

結論

どこか適当な場所でいいので*1require 'open-uri'をしてやる

私はconfig/initializers/extensions.rbというファイルを作り、そこに以下のように一行だけ書いて、Rails を再起動しました(重要)

require 'open-uri'

設定ファイルなどはまだ何もいじっていないのに、再起動したら一瞬でスタイルが適用されました(すごい!)。

f:id:gregminster:20170910102308p:plain

前提

  • 2017/09/10 現在です
  • Issues や Pull Requests は見ていません(すいません)

ダメだったときのログ

$ bundle exec rails generate kaminari:views bootstrap
Running via Spring preloader in process 4981
/home/USERNAME/APP_NAME/vendor/bundle/ruby/2.4.0/gems/kaminari-core-1.0.1/lib/generators/kaminari/views_generator.rb:114:in `initialize': No such file or directory @ rb_sysopen - https://api.github.com/repos/amatsuda/kaminari_themes/git/refs/heads/master (Errno::ENOENT)
(以下省略)

OKだったときのログ

$ bundle exec rails generate kaminari:views bootstrap3
Running via Spring preloader in process 5417
      downloading app/views/kaminari/_first_page.html.erb from kaminari_themes...
      create  app/views/kaminari/_first_page.html.erb
      downloading app/views/kaminari/_gap.html.erb from kaminari_themes...
      create  app/views/kaminari/_gap.html.erb
      downloading app/views/kaminari/_last_page.html.erb from kaminari_themes...
      create  app/views/kaminari/_last_page.html.erb
      downloading app/views/kaminari/_next_page.html.erb from kaminari_themes...
      create  app/views/kaminari/_next_page.html.erb
      downloading app/views/kaminari/_page.html.erb from kaminari_themes...
      create  app/views/kaminari/_page.html.erb
      downloading app/views/kaminari/_paginator.html.erb from kaminari_themes...
      create  app/views/kaminari/_paginator.html.erb
      downloading app/views/kaminari/_prev_page.html.erb from kaminari_themes...
      create  app/views/kaminari/_prev_page.html.erb

参考(感謝)

*1:というと規約に沿っていないとお叱りを受けますが

Powered by はてなブログ