LoginSignup
2
2

More than 5 years have passed since last update.

DeviseとRansack-->active_admin. Undefined Method "-eq"というerrorが出た時の対処法

Posted at

gem 'active_admin' をインストールして、設定をして管理したいモデルを読み込ませて
いざ、開いてみると colomn名 or method名 + "-eq" というerrorが吐かれた。
そんなの定義した覚えはなかったのに。。分からないので調べるとよくあるみたい?

has_manyやbelongs_toの多対多のリレーションと関係があるらしい。。

そこで

参考サイト!
http://stackoverflow.com/questions/21707959/how-to-fix-ransack-undefined-method-eq-when-using-activeadmin-with-through

app/admin/読み込んだmodel名.rbのファイル内を編集。
以下を追記

app/admin/user.rb
remove_filter :(例 user_roles  <--has_many, throughで定義したやつ

見てわかるようにerrorになってるcolumn等をfilterから外してあげると、解決できて管理画面も表示できる。


ちなみに僕の場合,テーブルに作ったカラム名や自動的に作られる :created_at, updated_at とかも引っかかって"created_at-eq"(はっきり覚えてないけど)みたいな感じで errorになってたので、これもfilterから外してあげる。

こんな感じ↓

app/admin/user.rb
remove_filter :start_time, :end_time, :created_at, :updated_at

avtive_adminの表示コラムを制限したいなどのカスタマイズは、こちらの方の投稿が大変参考になりました。ありがとうございました。
http://qiita.com/sa-wa-m/items/f999b82da2647bb4d513
http://qiita.com/hirooooooo/items/d1c4d7b93faf2683ba4d

active_adminのassetsが全体に反映される時の対処法はこちらが参考になりました。
http://blog.supermomonga.com/articles/rails/rails-activeadmin-css-issue.html#

以上。

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