Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8859009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:57:21+00:00 2026-06-14T14:57:21+00:00

I’m having a problem figuring out how to search across associations in the list

  • 0

I’m having a problem figuring out how to search across associations in the list views for models in the Rails_Admin interface.

Background information:

  • Models: Post, User, Hub, and Organization.
  • Objective: A user makes a post using a device which posts the http request through a hub device to the database. The database shows posts by users. A post belongs to a user, who sends the post through a device which belongs to a hub, and the hub belongs to an organization.
  • What I want to accomplish: In rails admin, I would like a custom field for the Post model to show the organization to which the user who made the post belongs.
  • Current problem: I can get the Post’s User’s organization to display as a string in the field by using the organization method for the Post model, but I can’t make a filter in Rails_admin that can make this searchable. In Rails_Admin, adding the line searchable :organization to config.model Post do...field :organization do{}end...end does not work.

I would really appreciate any advice on this matter. Thank you!

Post model:

class Post < ActiveRecord::Base

  belongs_to :user
  belongs_to :hub

  attr_accessible :hub_id, :user_id

  before_validation :set_count

  validates :hub_id, :presence => true
  validates :user_id, :presence => true
  validates :count, :presence => true, :numericality => {:greater_than_or_equal_to => 0}

  before_create :update_redis

  def organization
    self.hub.organization.name
  end

  def user_email
    self.user.email
  end

  private

  def user_email
    self.user.email
  end

end

User model:

class User < ActiveRecord::Base

  belongs_to :organization
  has_many :posts, :extend => User::Posts

  accepts_nested_attributes_for :organization

  attr_accessible :email, :password, :password_confirmation, :remember_me, :as => [:default, :admin]
  attr_accessible :device_id, :organization_id, :role_ids, :as => :admin
  attr_accessible :organization_attributes, :as => [:admin, :manager]

  after_save :update_total

end

Hub model:

class Hub < ActiveRecord::Base

  devise :token_authenticatable, :trackable

  belongs_to :organization, :inverse_of => :hubs
  has_many :posts

  attr_accessible :location, :organization_id, :as => :admin

  validates :organization, :presence => true
  validates :location, :presence => true

  before_save :ensure_authentication_token

end

Organization model:

class Organization < ActiveRecord::Base

  attr_accessible :name, :street_address_1, :street_address_2, :city, :state, :zip_code, :goal_per_hour, :as => [:admin, :manager
  ]
  has_many :hubs
  has_many :posts, :through => :hubs, :extend => Organization::Posts
  has_many :users

  validates :name, :presence => true, :uniqueness => true

end

rails_admin.rb initializer:

config.model Post do
  list do
    filters [:user, :hub]
    items_per_page 200
    field :id do
      column_width 50
    end
    field :count do
      column_width 35
    end
    field :user do
      column_width 50
    end
    field :user_email
    field :hub do
      column_width 50
    end
    field :organization do
      label "Organization"
      # searchable :organization # This line doesn't work!!
    end
    field :created_at do
      strftime_format "%m/%d/%y %H:%M"
      column_width 90
    end
    #field :updated_at do
    #  strftime_format "%m/%d/%y %H:%M"
    #  column_width 90
    #end
  end
  show do
    include_all_fields
    field :user_email
    field :organization_name, :string do
      label "Organization"
    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:57:22+00:00Added an answer on June 14, 2026 at 2:57 pm

    It looks like the documented answer does work – your line

    searchable :organization
    

    should be

    searchable :name
    

    and that will add an option for Organization (under the “Add Filter” menu) that searches the name field, but it won’t add searching on that field to the quick “Filter” input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I've tracked down a weird MySQL problem to the two different ways I was
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.