Rails: How do I pass custom params to a controller method?

后端 未结 3 520
Happy的楠姐
Happy的楠姐 2021-01-24 06:49

I am fairly new to Rails.

I want to track how often a post is read in order to rank them in order of popularity. Therefore, I will have a database column read_cou

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-24 07:13

    What about doing something like:

    @post.read_count.increment! unless user_signed_in? && current_user.admin?
    

提交回复
热议问题