obfuscate_id icon indicating copy to clipboard operation
obfuscate_id copied to clipboard

Rails 4.2: Unable to use obfuscate_id :spin => 89238723

Open ACPK opened this issue 10 years ago • 4 comments

https://github.com/namick/obfuscate_id/issues/28

ACPK avatar Feb 13 '15 20:02 ACPK

Any luck getting this gem to work with Rails 4.2?

Here's the error you get when using Rails 4.2 and devise:

Couldn't find User with an out of range value for 'id'

ACPK avatar Apr 30 '15 19:04 ACPK

@ACPK Can you provide the full stacktrace?

erikshestopal avatar Jun 15 '15 21:06 erikshestopal

Here's the stacktrace I get: Couldn't find User with an out of range value for 'id' /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.2/lib/active_record/core.rb:159:in rescue in find' /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.2/lib/active_record/core.rb:128:infind' /usr/local/lib/ruby/gems/2.2.0/gems/obfuscate_id-0.2.0/lib/obfuscate_id.rb:31:in `find'

By calling User.find(user_id)

johanoskarsson avatar Jun 22 '15 19:06 johanoskarsson

@johanoskarsson The reason why you're getting this is because Rails is trying to lookup the record with the id you provided in the URL params, and no record with that id exists. Try this:

User.find_by(user_id]) 
or 
User.find_by(params[:id)

erikshestopal avatar Jun 22 '15 23:06 erikshestopal