Skip to content

Instantly share code, notes, and snippets.

View courtsimas's full-sized avatar
🏠
Building

Court Simas courtsimas

🏠
Building
View GitHub Profile
@courtsimas
courtsimas / gist:965282
Created May 10, 2011 20:14
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 }