Im在我的Rails應用程序中設置活動管理員。我跑的生成器來創建用戶資源,但是當我在用戶點擊管理儀表板鏈接獲取:Active Admin NoMethodError錯誤
NoMethodError in Admin/users#index
Showing /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activeadmin-0.4.4/app/views/active_admin/resource/index.html.arb where line #1 raised:
undefined method `city_id_contains' for #<MetaSearch::Searches::User:0x007fde92d69840>
Extracted source (around line #1):
1: render renderer_for(:index)
我不知道什麼是產生這樣或錯誤所在..從任何想法來?謝謝! (請讓我知道如果你需要看到的任何其他文件)
型號:
user.rb
class User < ActiveRecord::Base
rolify
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :province_id, :city_id
belongs_to :province
belongs_to :city
province.rb
class Province < ActiveRecord::Base
has_many :cities
has_many :users
end
city.rb
class City < ActiveRecord::Base
belongs_to :province
has_many :users
end
schema.rb
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name"
t.date "date_of_birth"
t.string "address"
t.string "gender"
t.integer "zipcode"
t.string "city"
t.string "status"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.integer "province_id"
t.integer "city_id"
end
create_table "provinces", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "cities", :force => true do |t|
t.string "name"
t.integer "province_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
我在猜測city_id_contains是ActiveAdmin基於關係您的用戶模型共享與其他東西關係生成的方法。 你有什麼其他的模型,他們有什麼關係? – YuKagi
@YuKagi好的謝謝!添加相關模型...通過csv加載省/城市填充選擇列表(不確定是否相關) – js111
您還可以發佈您的schema.rb的相關部分嗎? – YuKagi