嘿,我在与我的用户模型相关的主动管理设置方面有点挣扎。我正在使用设计。
当我点击活动管理员中的用户标签时,我得到:
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
#