On Jueves, 8 de diciembre de 2011 14:15:05 anithri escribió: > class Project > has_many :events, :class_name => "EventLog" > end > > class EventLog > #attributes: event_type, event_date > end > > I want to setup a field search column for Project that gives me a select > list for Event Type as well as the normal date search fields. > > I'd like to be able to use #active_scaffold_search_date_bridge to setup the > date search form parts, and #condition_for_date_bridge_type (both in > lib/active_scaffold/bridges/shared/date_bridge.rb) so I don't have to > recreate them. But I need to be able to add an event_type select that > allows the user to choose the type of event to search for. The tricky > parts (as I see them) are 1. ensuring that the search form state is saved > and the existing selected values can be used to populate the search form > again. 2. ensuring that I don't repeat the code for setting up the form > element or the conditions output. 3. Doing it in a helper instead of > editing the active_scaffold code directly. > > I accept this is prolly not a safe way to do things, but I'm willing to > accept some brittleness in order to get it working. > > even a pointer to a code sample for a similar problem would be welcome. > > Thanks.
You should add event_type and event_date to your field_search columns: conf.columns << [:event_date, :event_type] # define columns conf.columns.exclude :event_date, :event_type # exclude from all actions conf.field_search.columns << [:event_date, :event_type] Then, you must set search_sql and search_ui for both columns. You can use :select search_ui for event_type and set the options, if options can change in each request use a before filter to set the available options. -- You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
