Skip to content

Instantly share code, notes, and snippets.

View MikeBlyth's full-sized avatar

Mike Blyth MikeBlyth

View GitHub Profile
@MikeBlyth
MikeBlyth / gist:4327614
Last active December 9, 2015 20:58
Mate normal Rails style form parameters to ActiveScaffold style. Module to include in ActiveScaffold controllers.
# Include this module to Rails controllers using ActiveScaffold to be able to receive
# form parameters in normal Rails format ( {... model: {...}}) and change them to the
# format needed by AS ({... record:{...}})
# ActiveScaffold also wants to see associations by name (xxxx) and not xxxx_id
# The module adds do_update and do_create methods, so these should not be overridden
# in the controller (unless the same functionality is added). Instead, you can override
# my_do_update and my_do_create, which are called by do_create and do_update just before
# they call the AS methods.
# The model name is determined from the controller class in @my_model_sym, which can be
# overridden if the model name should be something else.