2008/5/9 Leo Laksmana <[EMAIL PROTECTED]>:

>
>
> Pake block transaction aja. BTW ini kalo di controller yah?
>
> User.transaction do
>  begin
>     @user.update_attributes(params[:user])
>     @user.update_attributes(params[:address])
>  end
> end
>
>
Spesifically dalam problem ini:
def update
  User.transaction begin
    begin
      @user = User.find(params[:id])
      @user.update_attributes!(params[:user])
      @user.address.update_attributes!(params[:address])
    end

     redirect_to :action => 'list'
  end
rescue Exception
  @provinces = Province.find(:all)
  @countries = Country.find(:all)

  render :action => 'edit'
end


Perhatikan update_attributes! bukan update_attribute, agar throw exception.


[Non-text portions of this message have been removed]

Kirim email ke