Sutto / slugged

Super simple slugs for ActiveRecord 3+, with slug history. Formerly known as Pseudocephalopod.
MIT License
86 stars 16 forks source link

Is it possible to use slug -or- (not instead of) default id in routing? #25

Open ericpeters0n opened 10 years ago

ericpeters0n commented 10 years ago

Making a model sluggable appears to force the use of the slug in routing, rather than making it an option. Is it possible to use the slug -or- (not instead of) default row/model id in routing?

Sutto commented 10 years ago

To do this, you need to handle it manually - there isn't a super nice way. I'd suggest being explicit - Override #to_param on your model to return your preferred (e.g. id / slug) and then use the other explicitely. You could use a switch (ideally using Thread.current or something better - so it's request-local), but note that isn't super clean and it'd honestly be preferable to be explicit.