ユーザー モデルに関連するアクティブな管理者のセットアップに少し苦労しています。私はデバイスを使用しています。
アクティブな管理者の [ユーザー] タブをクリックすると、次のようになります。
NoMethodError in Admin/users#index
Showing /Users/bweidlich/.rvm/gems/ruby-1.9.3-p286/gems/activeadmin- 0.5.1/app/views/active_admin/resource/index.html.arb where line #1 raised:
undefined method `user_id_contains' for #<MetaSearch::Searches::User:0x007fc0a9831cf8>
Extracted source (around line #1):
1: insert_tag renderer_for(:index)
特定のユーザーを編集したい場合は、次のようになります。
NoMethodError in Admin/users#edit
Showing /Users/bweidlich/.rvm/gems/ruby-1.9.3-p286/gems/activeadmin-0.5.1/app/views/active_admin/resource/edit.html.arb where line #1 raised:
undefined method `user_id' for #<User:0x007fc0a47d3e28>
Extracted source (around line #1):
1: insert_tag renderer_for(:edit)
エラーをどこで探すべきか誰にも分かりますか?
いつものように、どんな助けでも大歓迎です!
みんなありがとう
編集:
アプリのユーザー モデル
class User < ActiveRecord::Base
rolify
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable
attr_accessible :role_ids, :as => :admin
attr_accessible :username, :first_name, :last_name, :email, :password, :password_confirmation, :remember_me, :avatar, :bio, :title, :company,:facebook,:twitter,:pinterest,:linkedin
validates_presence_of :username
validates_uniqueness_of :username, :email, :case_sensitive => false
has_many :events
has_many :relationships, foreign_key: "follower_id", dependent: :destroy
has_many :reverse_relationships, foreign_key: "followed_id",
class_name: "Relationship",
dependent: :destroy
has_many :followers, through: :reverse_relationships, source: :follower
has_many :followed_users, through: :relationships, source: :followed
has_many :comments
has_one :avatar
def update_without_password(params={})
params.delete(:current_password)
super(params)
end
def following?(other_user)
relationships.find_by_followed_id(other_user.id)
end
def follow!(other_user)
relationships.create!(followed_id: other_user.id)
end
def unfollow!(other_user)
relationships.find_by_followed_id(other_user.id).destroy
end
end
アクティブな管理者ユーザー モデル:
ActiveAdmin.register User do
form do |f|
f.inputs "User Details" do
f.input :email
f.input :password
f.input :password_confirmation
f.input :superadmin, :label => "Super Administrator"
end
f.buttons
end
create_or_edit = Proc.new {
@user = User.find_or_create_by_id(params[:id])
@user.superadmin = params[:user][:superadmin]
@user.attributes = params[:user].delete_if do |k, v|
(k == "superadmin") ||
(["password", "password_confirmation"].include?(k) && v.empty? && !@user.new_record?)
end
if @user.save
redirect_to :action => :show, :id => @user.id
else
render active_admin_template((@user.new_record? ? 'new' : 'edit') + '.html.erb')
end
}
member_action :create, :method => :post, &create_or_edit
member_action :update, :method => :put, &create_or_edit
end
ユーザー テーブル スキーマ
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255)
# encrypted_password :string(255)
# reset_password_token :string(255)
# reset_password_sent_at :datetime
# remember_created_at :datetime
# sign_in_count :integer
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# created_at :datetime
# updated_at :datetime
# username :string(255)
# bio :text
# title :string(255)
# company :string(255)
# facebook :text
# twitter :text
# pinterest :text
# linkedin :text
# confirmation_token :string(255)
# confirmed_at :datetime
# confirmation_sent_at :datetime
# unconfirmed_email :string(255)
# first_name :string(255)
# last_name :string(255)
# avatar :string(255)
# avatar_id :integer
#