My favorites | Sign in
Project Logo
          
Search
for
Updated Feb 11, 2008 by cainlevy
Labels: Featured
ControllerSetup  
How to configure RecordSelect on your controllers

RecordSelect configures through one method with optional arguments, like this:

class UsersController < ApplicationController
  record_select :search_on => [:first_name, last_name]
end

The options you can pass are:

  • :model: the name of the model you want to expose. defaults based on the name of the controller
  • :per_page: how many records to show per page when browsing
  • :notify: a method name to invoke when a record has been selected, if you want server-side notification.
  • :order_by: a SQL string to order the search results
  • :search_on: a field name, or an array of field names. these fields will each be matched against each search term.
  • :full_text_search: a boolean for whether to use a %?% search pattern or not. default is false.
  • :label: a proc that accepts a record and returns a descriptive string. the default one calls :to_label on the record.
  • :include: as for ActiveRecord::Base#find. can help with search conditions or just help optimize rendering the results.


Comment by caoweiyuan, Jan 28, 2008

Can I wish an include option? like this:

class UsersController? < ApplicationController?

record_select :search_on => "roles.name", :include => :roles
end

Comment by cainlevy, Jan 28, 2008

Sure, put that wish in the Issues section.

Comment by gabriel.sobrinho, Jun 18, 2009

Cainlevy, nothing for now? I need this option also ;)


Sign in to add a comment
Hosted by Google Code