Ruby on Rails Thursday, January 14, 2016

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

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/35b707fe96b326ad7f2de00d8c514fad%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment