scripts1988 / quan_blog

The pre-work project for Ruby on Rails course of CoderSchool
0 stars 0 forks source link

Thanks! #1

Open coderschoolreview opened 7 years ago

coderschoolreview commented 7 years ago

Hi @scripts1988, thanks for your hard work on pre-work submission.

Great things:

Suggestions:

def details @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)

# Increase 1 unit for view
@article = Article.find(params[:id])
@article.view += 1
Article.update(params[:id], view: @article.view)

@comment_list = Comment.where(:article_id => params[:id]).order("updated_at DESC")
@number_of_comment = @comment_list.count

end

AFTER

def show @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)

Handle view count using increment

# Details about increment here: http://apidock.com/rails/ActiveRecord/Base/increment!
@article.increment!(:view)

@comment_list = Comment.where(:article_id => params[:id]).order("updated_at DESC")
@number_of_comment = @comment_list.count

end

- Last but not least, you should have validation in your model to prevent user input wrong/empty record. This is sample: 

```ruby 
# article.rb
validates :title, :body, presence: true
# comment.rb
validates :message, presence: true

Just some feedback to improve your app. Feel free to edit and update your submission then tell us to re-check it. If you have any questions or you need any support, feel free to contact us via gitter chat or email us.

scripts1988 commented 7 years ago

Hello CoderSchool,

Thanks so much for your review and let me improve my app.

I fixed all above point, except using show instead details. The idea is, I want to count view only when user visit the post by click on post title at home page. If we merge details to show, the view counter is also increased when user updated a post successfully or click on Show button.

Looking forward your feedback.

coderschoolreview commented 7 years ago

Hi @scripts1988, Glad to hear that you'll fix and update your app. We'll wait for that.

Actually, you don't need to have show button to redirect user to article's content and show method can handle view counter itself. We love to discuss more about this with you when you start learning with us.

Let's schedule a quick call to confirm that this course is a right fit for you. We also would like to know a little more about your experience. Please book a slot from here.

scripts1988 commented 7 years ago

Hello @coderschoolreview, I fixed all review point already. You can check it (exclude show/details point) I will check and confirm slot