Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting undefined method `user_id' in Active Admin
    primarykey
    data
    text
    <p>Hey I'm struggling a bit with the active admin setup related to my user model. I'm using devise.</p> <p>When I click on the User tab in active admin I get:</p> <pre><code>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 #&lt;MetaSearch::Searches::User:0x007fc0a9831cf8&gt; Extracted source (around line #1): 1: insert_tag renderer_for(:index) </code></pre> <p>and when I want to edit one particular user I get:</p> <pre><code>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 #&lt;User:0x007fc0a47d3e28&gt; Extracted source (around line #1): 1: insert_tag renderer_for(:edit) </code></pre> <p>Does anyone have an idea where I should look for the error?</p> <p>As always, any help would be greatly appreciated!</p> <p>Thanks guys</p> <p>EDIT:</p> <p>App user model</p> <pre><code>class User &lt; ActiveRecord::Base rolify devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable attr_accessible :role_ids, :as =&gt; :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 =&gt; 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 </code></pre> <p>active admin user model:</p> <pre><code>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 =&gt; "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) &amp;&amp; v.empty? &amp;&amp; !@user.new_record?) end if @user.save redirect_to :action =&gt; :show, :id =&gt; @user.id else render active_admin_template((@user.new_record? ? 'new' : 'edit') + '.html.erb') end } member_action :create, :method =&gt; :post, &amp;create_or_edit member_action :update, :method =&gt; :put, &amp;create_or_edit end </code></pre> <p>users table schema</p> <pre><code># == 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 # </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload