All pastes #947292 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-03-18 12:06 UTC
rendered paste body
  # PUT /projects/1
  # PUT /projects/1.xml
  def update
    @project = Project.find(params[:id])
    begin
      @client = Client.find(params[:project][:client_id])
      respond_to do |format|
        if @project.update_attributes(params[:project])
         flash[:notice] = 'Project was successfully updated.'
         format.html { redirect_to(@project) }
         format.xml  { head :ok }
        else
         format.html { render :action => "edit" }
         format.xml  { render :xml => @project.errors, :status => :unprocessable_entity }
        end
      end
    rescue ActiveRecord::RecordNotFound => bang
      @project.errors.add('Client ');
      #@project.errors.add(bang);
      #@project.errors.add(params.inspect);
      respond_to do |format|
        format.html { render :action => "edit" }
        format.xml  { render :xml => @project.errors, :status => :unprocessable_entity }
      end
    end
  end