jcypret / hashid-rails

Use Hashids (http://hashids.org/ruby/) in your Rails app ActiveRecord models.
MIT License
349 stars 48 forks source link

Rails own 'form_for' / 'form_with' helper #50

Open skorth opened 6 years ago

skorth commented 6 years ago

Hey there,

nice to see hashid turning into its own rails gem. But what about form_for and form_with helpers in Rails? If i want to obscure ID's within URL's it works fine. Using form_for would generate its CLASS and ID automatically by using to_key and reveal the original ID within the DOM. What do you think, is that something that should be addressed?

jcypret commented 6 years ago

Hi @skorth. Thanks for bringing this up! I was able to recreate using the view helper dom_id(@model, :action). Hadn't considered that scenario before.

Looks like overriding to_key instead of to_param would sort things out, but need to review typical usage. It makes sense conceptually that the model's key would be the hashid, not the database id.

mikehatfield commented 1 year ago

@jcypret Any updated thoughts on this topic?