I am using rails admin and have two simple models:
class Spot < ActiveRecord::Base
has_many :user_spots
end
class UserSpot < ActiveRecord::Base
belongs_to :spot
end
RailsAdmin.config do |config|
config.model UserSpot do
exclude_fields :id, :created_at, :updated_at
end
end
when I am adding a new Spot in the admin area, it shows the dropdown list correctly,

but when I start typing, it executes the following sql by default:
Spot Load (0.6ms) SELECT `spots`.* FROM `spots` WHERE ((LOWER(spots.name) LIKE '%n%') OR (LOWER(spots.about) LIKE '%n%') OR (LOWER(spots.hours) LIKE '%n%') OR (LOWER(spots.location) LIKE '%n%') OR (LOWER(spots.call_info) LIKE '%n%') OR (LOWER(spots.website) LIKE '%n%') OR (LOWER(spots.menu) LIKE '%n%')) ORDER BY spots.id desc LIMIT 30
I would like to search only for name. Is it possible?
You can configure the same as:
RailsAdmin.config do |config|
config.model UserSpot do
exclude_fields :id, :created_at, :updated_at
list do
field :about do
searchable false
end
field :hours do
searchable false
end
# Like this mark false all the fields you don't want to
# search. By default all fields are searchable.
end
end
end
Check this wiki for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With