It’s common to use pseudo-slugs in Ruby on Rails apps. You do something like
1 2 3 4 5 6 7
The Rails URL helpers will now use this parameter in URLs instead of just the
id. Controller actions can usually be left unchanged since
ActiveRecord::Base#find will run
to_i on the parameter string, lopping off the slug.
These pseudo-slugs let people mess with you, though. They could pass your
http://example.com/items/1-foo URL to someone else as
http://example.com/items/1-ugly-ass-foo and it will work fine. It may even be indexed by search engines that way.
This is easy to overlook, but the solution is fairly obvious and simple:
1 2 3 4 5 6 7 8 9 10 11 12
:overwrite_params will ensure any additional parameters are unchanged.
If you need this for more than just the
show action, you might move it to a separate method, perhaps used as a