Search code examples
ruby-on-railsruby-on-rails-3.2link-to

Can I use something other than id with link_to in my rails view?


The rails way of making links in your view is to use link_to. Passing it an object will link to that object's id. How can I use my object's match_id instead of id with link_to?


Solution

  • You can override the to_param method in your model to return the value of match_id to have link_to and other rails helpers automatically use that value when generating urls.