title: When to use private method in Rails?
body: <p>I'm not entirely sure about the concept of private method in rails, and when and how to use it. Are there any rules? what are the differences between private vs public, vs protected? For example, in the following example, why is private method being used here instead of the other two methods. Is it best practice to always use private method for user generated input? Please enlighten me. Many thanks!</p>
  
  <pre><code>class PostsController &lt; ApplicationController
  
  def index
    @posts = Post.all.order("created_at DESC")
  end
  
  def new
   @post = Post.new
  end
  
  def create
   @post = Post.new(post_params)
    if @post.save
   redirect to @post
   else
    render 'new'
   end
  end
  
  def show
    @post = Post.find(params[:id])
  end
  
  private
  
  def post_params
    params.require(:post).permit(:title, :body)
   end
  end
  </code></pre>