Skip to content

Commit

Permalink
Fix bugs in update proposal api.
Browse files Browse the repository at this point in the history
  • Loading branch information
guanxiaohua2k6 committed Dec 13, 2011
1 parent 597845a commit a597fd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/controllers/proposals_controller.rb
Expand Up @@ -121,18 +121,18 @@ def update

if @proposal.update_attributes(params[:proposal])
@proposal.state = "init"
if @proposal.save
respond_to do |format|
format.html { redirect_to(proposals_url) }
format.json { render :json => @proposal.as_json, :location => @proposal }
end
else
respond_to do |format|
format.html { render :action => "new" }
format.json { render :json => {:errors => @proposal.errors}.as_json }
end
@proposal.save
respond_to do |format|
format.html { redirect_to(proposals_url) }
format.json { render :json => JSON.pretty_generate(@proposal.as_json) }
end
else
respond_to do |format|
format.html { render :action => "new" }
format.json { render :json => {:errors => @proposal.errors}.as_json }
end
end

end

def destroy
Expand Down
1 change: 1 addition & 0 deletions public/javascripts/rest_apis/index.js
Expand Up @@ -165,6 +165,7 @@ function do_click_exec_btn(btn) {
alert("Succeeded.");
},
error: function(data) {
$("#" + action + "_result_textarea").attr("rows", 1).val("");
alert("Error occurred!!!");
},
complete: function() {
Expand Down

0 comments on commit a597fd5

Please sign in to comment.