Git Product home page Git Product logo

Comments (4)

tyraeltong avatar tyraeltong commented on June 27, 2024

I'm having the same issue. I've tested several scenarios, seems this issue will happen only when using :only with devise gem.

from audited.

tyraeltong avatar tyraeltong commented on June 27, 2024

More information after a bit of research: It's caused by the
devise_for :users
that devise added to the routes.rb.
rake tasks will load rails environment first which in turn load the all the route definitions from routes.rb, and because of devise_for :users, devise will call it's add_mapping method and eventually use your User model definition. This triggered the acts_as_audited call, and in that call, if you have :only option set, it'll check model's table column_names, but at this time the table doesn't exists yet, thus here comes the issue.

So one work around would be comment out the devise_for :users in your routes file before you do db migration from scratch and then uncomment it. This is ugly but still have no idea how to fix it.

from audited.

fdeschenes avatar fdeschenes commented on June 27, 2024

This is a really old issue, which unfortunately is still unresolved as of 4.2. Rather than commenting code out, I solved the issue this way:

class User < ActiveRecord::Base
  audited if self.table_exists?

  ...
end

If/when I have more time, I'll look into adding a check and submitting a pull request.

from audited.

laserlemon avatar laserlemon commented on June 27, 2024

@fdeschenes Thank you for the workaround. Yes, please submit a PR (if you haven't already). Thank you!

from audited.

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.