how to place pagination limit per page in rails controller

How to get dynamic page count in each controller using will_paginate gem and how to use gem shown below.

use will_paginate gem in Gemfile and run bundle install

you can change the count of parameter per_page as you preference.

write this code in controller

def company_search 
     @companies = Company.all.paginate(page: params[:page], per_page: 10) 
end

# render your companies data with render or @companies.each do |company|
render @companies

# pagination in html file
<%= will_paginate @companies %>