2

When I edit a record that has a belongs_to association in ActiveAdmin, I'd like to search for potential records instead of choosing from a select list (the default option).

For example, I have a Post object that belongs to User. When I edit a post, I'd like to be able to search for a user to change the who owns the Post, but currently I have to choose from a select list of existing users. The list is so large that some users are not included on the list.

# app/models/user.rb
class User < ActiveRecord::Base
  attr_accessible :name
  has_many :posts
end

# app/models/post.rb
class Post < ActiveRecord::Base
  belongs_to :post
end

# app/admin/posts.rb
ActiveAdmin.register Post do
  index do
    column :user do |post|
      link_to post.user.name, admin_user_path(post.user)
    end
    column :content
  end

  form do |f|
    # What goes here to search for a user instead of choosing one from the dropdown?
  end
end
Nathan Hurst
  • 1,740
  • 14
  • 22
  • afaik there is nothing that could accomplish this at the moment. you might simply switch to an input field to enter the user-id and have some sidebar with a list of user or the like. – phoet Nov 16 '11 at 20:56

0 Answers0