Custom methods routing - rails 3

Hi everyone

I have a problem with a couple of methods I’ve created.

The first method looks like the “edit” method but I’ve renamed to
“aprove” this method load a form with some editable fields

def aprove
@buy_order = BuyOrder.find(params[:id])
end

The second method looks like “update”, the name is “result”, but it
should execute just after I click “submit” in the aprove form. But
when I click “submit”… the “update” method is executed instead

def result
@buy_order = BuyOrder.find(params[:id])
respond_to do |format|
if @buy_order.update_attributes(params[:buy_order])
format.html { redirect_to(@buy_order) }
format.xml { head :ok }
else
format.html { render :action => “aprobar”}
format.xml { render :xml => @buy_order.errors, :status
=> :unprocessable_entity }
end
end
end

What I have to do to make this work correctly? (correctly is: when I
click “submit” in the form for “aprove” then “result” has to execute)

Can you help me?

On 10 August 2011 16:31, Angelo C. [email protected] wrote:

The second method looks like “update”, the name is “result”, but it
should execute just after I click “submit” in the aprove form. But
when I click “submit”… the “update” method is executed instead

When you click submit in the aprove form the action that is run
depends on the code in that view. It is there that you must look to
see what action you have asked it to perform.

Colin