Table of Contents
gem の Cells 3 を Cells 4 にアップグレードした際に遭遇したエラーと対処法を記録しておきます。 すべてではないです。 ここにある対処法は、 それぞれの Cell クラス に対して行ってもいいですが、 ApplicationCell という親クラスを作ってそこに書き込むのが楽です。
対処した最終結果は Rails: Cells 3 から Cells 4 へのアップグレード に記載しています。
helper_method がないというエラー
lib/devise/controllers/helpers.rb で次のようなエラーが出ます。 そのとき私が使っていた devise のバージョンは 3.5.2 です。
undefined method `helper_method’ for XyzCell:Class
Cell クラス に次のコードを追加します。
|
1 2 |
def self.helper_method(*) end |
なにもしないメソッドですが問題ありません。 Cells 3 の時は self.helper_method を呼ぶ必要があったのですが、 Cells 4 からは 使わなくてもよくなり、 メソッドも削除されたそうです。
dom_class でエラー
次のようなエラーが出た場合。
undefined method `dom_class’ for #<XyzCell:0x007ff36d4fecb0>
Cell クラス に 次のコードを追加します。
|
1 2 3 4 5 6 7 |
def dom_class(record, prefix = nil) ActionView::RecordIdentifier.dom_class(record, prefix) end def dom_id(record, prefix = nil) ActionView::RecordIdentifier.dom_id(record, prefix) end |
数字の3桁区切り number_with_delimiter がなくてエラー
Cell クラス に include ActionView::Helpers::NumberHelper を追加します。
select タグ が使えなくてエラー
次のようなエラーメッセージが出ます。
private method `select’ called for #<XyzCell:0x007ff48f4febe8>
Cell クラス に include ActionView::Helpers::FormOptionsHelper を追加します。
参考: apotonick/cells Issue select form_helper doesn’t work in cells 4