Active Admin NoMethodError Error

大城市里の小女人 提交于 2019-12-06 09:47:18

This question helped me solve my problem. I had to read the comments to figure out how to solve it so I am providing the answer here:

If you have a model that contains a belongs_to relationship, Active Admin will not like it if you have a column name that matches your belongs to foreign key id column name.

For instance in this case your foreign key is 'city_id' but you also have a column named 'city'. Active Admin doesn't like this. And likewise it really doesn't make sense to have that column to begin with. Since you will access the city through the relationship.

To fix this you should create a migration that removes the city column.

class RemoveCityFromUser < ActiveRecord::Migration    
  def up 
    remove_column :users, :city
  end
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!