I have an integer in my Parent Object's table called completion_status with a default value of 0. Id like to set this to the same value as "@parent.child.count('completion', :distinct => true)", but I have no idea how to do this in the controller, or even if the controller is the best place to do this.
I know there's not much information included here, but let me know if I'm missing something important. I'm having kind of a brain-fart moment here.
EDIT: Just tried:
def set_completion
@app = App.find(params[:id])
@app.update_attribute(:completion_status => @app.elements.count('completion', :distinct => true))
end
update_attributebut I get awrong number of arguments (1 for 2)error. Check the edit.update_attributeexpects 2 arguments: the name of the attribute and the vale you're updating it to eg:update_attribute(:quantity, 42)(which differs fromupdate_attributeswhich takes name/value pairs as a hash)