GithubHelp home page GithubHelp logo

Comments (5)

namick avatar namick commented on August 16, 2024

You never have to manually call deobfuscate_id.

Just make sure you include obfuscate_id in your model:

class Bill < ActiveRecord::Base
  obfuscate_id

  # model code
end

Then just do this:

bill = Bill.find(params[:id])
bill.update_attributes(bill_params)

Feel free to reopen the issue if you are still having a problem.

from obfuscate_id.

jurezove avatar jurezove commented on August 16, 2024

I was encountering this when using CarrierWave and uploading attachments.

Not sure what the problem was but ended up doing a monkey patch and overriding #has_obfuscated_id? when uploading an attachment. :)

from obfuscate_id.

scottbullard avatar scottbullard commented on August 16, 2024

@jurezove can you elaborate on what you did to work around your issue by using has_obfuscated_id?

I am experiencing similar problems with trying to use obfuscate_id with carrierwave. No matter which method I use (find(obf_id) or find_by_id(orig_id)), carrierwave still has problems with an out of range value for 'id'

I had posted here a while back when at the time I believed it to be related to Resque, but it's also noted here quite some time ago but that fix referenced does not appear to work for this.

from obfuscate_id.

jurezove avatar jurezove commented on August 16, 2024

Hey @scottbullard sorry for the late reply. In the end, I did a small hack:

module HackableObfuscate
  def perform_deobfuscated
    result = false
    begin
      hack_class
      result = yield
    ensure
      unhack_class
    end
    result
  end

  private

  def hack_class
    self.class_eval do
      def self.has_obfuscated_id?
        false
      end
    end
  end

  def unhack_class
    self.class_eval do
      def self.has_obfuscated_id?
        true
      end
    end
  end
end

Then for example, called that method:

Payment.perform_deobfuscated { @payment.update_attributes(payment_params) }

Does something like this work for you?

from obfuscate_id.

scottbullard avatar scottbullard commented on August 16, 2024

@jurezove thanks - I will give that a try.

from obfuscate_id.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.