Giter Site home page Giter Site logo

Comments (6)

schneems avatar schneems commented on August 18, 2024

You don't need the rack_app block, it will never be called.

Rails isn't loaded when the rakefile gets loaded, it gets loaded once you call a task. So you're trying to use a constant before it's been defined. Unfortunately my docs in the readme are wrong. I thought I added an entry point where these things could be defined, but I don't see it in the code. Here's a short term workaround you could use

class MyAuthHelper < DerailedBenchmarks::AuthHelpers::Devise
  def user
    @user ||= begin
       User.find_or_create!(email: "[email protected]")
    end
  end
end

DerailedBenchmarks.auth = MyAuthHelper.new

from derailed_benchmarks.

bitcoder avatar bitcoder commented on August 18, 2024

thanks @schneems , the workaround works ;)

from derailed_benchmarks.

bitcoder avatar bitcoder commented on August 18, 2024

just to let you know that I had to add the method "call" to MyAuthHelper as bellow (I modified the login_as line), or else it would fail with unauthorized request in the app's controllers "before_action: authenticate_user!" from devise.

class MyAuthHelper < DerailedBenchmarks::AuthHelpers::Devise
  def user
    @user ||= begin
       User.find_or_create!(email: "[email protected]")
    end
  end

  # Logs the user in, then call the parent app
  def call(env)
    login_as(user, scope: :user)
    app.call(env)
  end

end

DerailedBenchmarks.auth = MyAuthHelper.new

from derailed_benchmarks.

schneems avatar schneems commented on August 18, 2024

That's weird since it's the exact same code https://github.com/schneems/derailed_benchmarks/blob/c47ef5488bcf2520821b549387476cb889b8afaa/lib/derailed_benchmarks/auth_helpers/devise.rb#L29-L32

Your subclass should have picked that up.

from derailed_benchmarks.

bitcoder avatar bitcoder commented on August 18, 2024

well, it's not exactly the same.. I'm using

login_as(user, scope: :user)

from derailed_benchmarks.

monkbroc avatar monkbroc commented on August 18, 2024

You can now do DerailedBenchmarks.auth.user = -> { User.find_or_create!(email: "[email protected]") } on the master branch. Are you OK to close this @bitcoder?

from derailed_benchmarks.

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.