iprog.com

active_scaffold overrides

the active_scaffold plugin for rails can be useful at times. as is typical of a large library, when it doesn’t do quite what you want, you have to start overriding parts of it.

unfortunately, there aren’t a lot of documented options to doing this with active_scaffold—at least not in the published docs. the code comments discuss more available options. so, what follows is an attempt to document some of those options.

i have used some of these, but not all of them. i don’t promise they work as advertised or even at all.

helper methods

these are helper methods that can be created for a specific controller.

render_{column_name}_{column_calculate}
file:
{column_name}_form_column(record, input_name)
file: lib/helpers/form_helpers.rb

when to define: to do custom rendering of the form widget for a particular column

{column_name}_column(record)
file: lib/helpers/list_helpers.rb

when to define: to do custom rendering of the record value

clean_column_value(value)
file: lib/helpers/list_helpers.rb

when to override: if you want to substitute a different default sanitization method for all columns. default is h(value).

controller methods

return_to_main
file: lib/actions/core.rb

when to override: if the ActiveScaffold is used as a component on another controllers page

conditions_for_collection
file: lib/actions/core.rb

when to override: define additional conditions to be used when querying a recordset

do_new
file: lib/actions/create.rb

when to override: to extend creation of @record in the new method, perhaps to add default values

before_create_save(record), after_create_save(record)
file: lib/actions/create.rb

when to override: when a hook is needed into the create method

create_authorized?
file: lib/actions/create.rb

when to override: when customizing handling of authorization for new/create methods

do_destroy
file: lib/actions/delete.rb

when to override: to customize the process of actually destroying a record

delete_authorized?
file: lib/actions/delete.rb

when to override: when customizing handling of authorization for delete/destroy methods

field_search_authorized?
file: lib/actions/field_search.rb

when to override: when customizing handling of authorization for the show_search method

list_authorized?
file: lib/actions/list.rb

when to override: when customizing handling of authorization for index/table/update_table/row/list methods

live_search_authorized?
file: lib/actions/live_search.rb

when to override: when customizing handling of authorization for the show_search method

do_nested
file: lib/actions/nested.rb

when to override: to customize how the parent/source record is found when nesting

search_authorized?
file: lib/actions/search.rb

when to override: when customizing handling of authorization for the show_search method

do_show
file: lib/actions/show.rb

when to override: change the default finding of @record for show

show_authorized?
file: lib/actions/show.rb

when to override: when customizing handling of authorization for the show method

do_edit
file: lib/actions/update.rb

when to override: change the default finding of @record for edit

before_update_save(record)
file: lib/actions/update.rb

when to override: if you need to inject data into the record before the update is saved

update_authorized?
file: lib/actions/update.rb

when to override: when customizing handling of authorization for edit/update methods

active_scaffold_controller_for(klass)
file: lib/active_scaffold.rb

when to override: to extend or customize the logic for determining class names of other ActiveScaffold controllers to facilitate nested controllers build on AR relationships

model methods

scaffold_update_nofollow
file: lib/extensions/active_record.rb

when to define: to indicate what associations should not be followed by active scaffold’s update mechanism

scaffold_update_follow
file: lib/extensions/active_record.rb

when to define: to indicate what associations should be followed only by active scaffold’s update mechanism

css selectors
file: lib/helpers/list_helpers.rb

notes: each column that is rendered by the default AS widget helpers is given one or more special classes:

tags: active scaffold, rails

by Mike B

Thanks! Now, why can’t such useful information be easily accessible in the documentation?