I am a student and I got the memo (without explanation) that my following code is flawed and can be much better. How would you improve my controller/reviewname method? Thank you for your time!
class ReviewController < ApplicationController
def index
@reviews = Review.all.order(created_at: :desc)
end
def newname
@review = Review.find(params[:id])
if @review.update_attribute(:title, sanitize(params[:title]))
format.json { render json: { status: 200 } }
else
format.json { render json: { status: 500 } }
end
end
end
Aucun commentaire:
Enregistrer un commentaire