Displaying 1 result from an estimated 1 matches for "edit_cod".
Did you mean:
edit_code
2006 Jun 08
3
Macros and stuff
...identical. So first I DRY''d the four methods in
each controller to just one and then I decided to write a single macro
for all my controllers.
This is the macro:
def self.edit_action_for(model, options = {})
model_class = Object.const_get(model)
define_method(:edit) do
edit_code = lambda do
@thing = model_class.find_by_id(params[:id]) || model_class.new
if request.post?
@thing.attributes = params[:impactable_area]
if @thing.save
flash[:notice] = "#{model.humanize} successfully saved."
redirect_to :actio...