Git Product home page Git Product logo

Comments (2)

RudyOnRails avatar RudyOnRails commented on September 13, 2024 3

And if anyone on rails 5 runs into this that needs to migrate before waiting for fix, just follow the gem's README directions as normal, but after running rails generate acts_as_follower, and before migrating, change the migration to add your rails version (note the added [5.1] or whatever rails version you're on:

class ActsAsFollowerMigration < ActiveRecord::Migration[5.1]
  def self.up
    create_table :follows, force: true do |t|
      t.references :followable, polymorphic: true, null: false
      t.references :follower,   polymorphic: true, null: false
      t.boolean :blocked, default: false, null: false
      t.timestamps
    end

    add_index :follows, ["follower_id", "follower_type"],     name: "fk_follows"
    add_index :follows, ["followable_id", "followable_type"], name: "fk_followables"
  end

  def self.down
    drop_table :follows
  end
end

Then migrate as normal, and you should be 👍

from acts_as_follower.

thatosmk avatar thatosmk commented on September 13, 2024

I also came across this issue after installing this gem today. I looked at #111 and I noticed that the fixed for this has not been merged. This worked for me also

if ActiveRecord.gem_version >= Gem::Version.new('5.0')
   class ActsAsFollowerMigration < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]; end
else
   class ActsAsFollowerMigration < ActiveRecord::Migration; end
end
ActsAsFollowerMigration.class_eval do
def self.up
    create_table :follows, force: true do |t|
      t.references :followable, polymorphic: true, null: false
      t.references :follower,   polymorphic: true, null: false
      t.boolean :blocked, default: false, null: false
      t.timestamps
    end

    add_index :follows, ["follower_id", "follower_type"],     name: "fk_follows"
    add_index :follows, ["followable_id", "followable_type"], name: "fk_followables"
  end

  def self.down
    drop_table :follows
  end
end

from acts_as_follower.

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.