How to use company_name on the url instead of company_id

Hi all, How to use company_name on the url instead of company_id.

This is my routes:

get ‘company/:company_id’ => ‘company#company’, as: :company

This is my controller:

@company_view = Company.find(params[:company_id])

This is view:

<%=link_to company.company_name, company_path(:company_id => company_id)
%>

Thanks

On Thu, Jan 14, 2016, at 21:01, Shabbir A. wrote:

Hi all, How to use company_name on the url instead of company_id.

This should help.

http://api.rubyonrails.org/classes/ActiveRecord/Integration/ClassMethods.html#method-i-to_param