Ruby on Rails
Tuesday, June 2, 2015
I made this code but someone told me it was flawed
How would you improve this piece of code in the reviewcontroller (mainly the namereview method)?class ReviewController < ApplicationController
before_action :set_reviews, only: [:show, :edit, :update, :destroy]
def index
@reviews = Review.all
end
def namereview
@review = Review.find(params[:id])
if @review.update_attribute(:description, sanitize(params[:description]))
format.json { render json: { status: 200 } }
else
format.json { render json: { status: 500 } }
end
end
end
Thanks in advance
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9d45ff69-e768-42d4-8faf-10803154c01d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment