I have a rails app where many of the models are editable using best_in_place, so I have a lot of controllers that look partially like this:
before_action :find_objects, except: [:new, :create]
def update
@object.update_attributes(object_params)
respond_to do |format|
format.json { respond_with_bip @object}
end
end
private
def object_params
params.require(:object).permit(:foo, :bar)
end
def find_objects
@object = Object.find(params[:id])
end
How do I move this particular repeated piece into a controller concern, given that the object being updated is going to come in with a particular name in the params hash, and object_params and find_objects should call their proper versions based on the model name? Is there some elegant meta-magic that'll sort this all out?