Skip to content

Instantly share code, notes, and snippets.

@courtsimas
Created May 10, 2011 20:14
Show Gist options
  • Save courtsimas/965282 to your computer and use it in GitHub Desktop.
Save courtsimas/965282 to your computer and use it in GitHub Desktop.
questions_controller update action
def update
@question = current_user.questions.find(params[:id])
message = "Your question needs to be between 10 and 255 characters"
if @question.update_attributes(params[:question])
flash[:notice] = message = "Got it! Thanks for updating your question."
status = 200
end
respond_to do |format|
format.html { redirect_to @question }
format.json { render :json => { :message => message, :status => status, :body => @question.body } ; flash.discard }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment