Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

4
4

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 5 years have passed since last update.

Roo v2 へのアップデート

Posted at

前置き

RailsでExcelファイルを読み込むのにRooを使っている人がどれくらいいるか分かりませんので、需要あるのか?微妙ですが

bundle updateの恐怖

ある日不用意にbundle updateしてしまい、Rooがv1.13からv2.0に上がっていることに気づかず、Excelファイルのインポート機能が動作していないとクレームが来ることに。。。

何が起こってる?

Roo::Excelx.new で「ArgumentError (wrong number of arguments (3 for 1..2))」

あれ?メソッドの仕様が変わっている!!
とりあえずヴァージョン1.13に戻して調査することに

仕様変更

version1.13.2
def initialize(filename, options = {}, deprecated_file_warning = :error)

だったので
Roo::Excelx.new(@file.path, nil, :ignore)
と呼んでいたのですが

version2.0.0
def initialize(filename, options = {})

となっています。

deprecated_file_warningどこいった?と思いましたがinitialize内で
file_warning = options.fetch(:file_warning, :error)
とあるのでoptionsに入れてしまえばいいでしょう

Roo::Excelx.new(@file.path, :file_warning => :ignore)

旧フォーマット(xls)も使いたい

Roo::Excelは別ライブラリに移行してしまいました
roo-xls のGEMを追加しましょう

4
4
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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?