Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 1.21 KB

UPGRADE.md

File metadata and controls

49 lines (32 loc) · 1.21 KB

Upgrade notes

Breaking changes with v0.7.0

There are two important changes needing your attention. Please read the following hints carefully!

Polymorphic readers

The gem accepts any type of classes as reader and it's not limited to User class anymore. So you can do stuff like:

Customer.have_not_read(message1)
message1.mark_as_read! for: Customer.find(1)

If you are upgrading from v0.6.3 or older, you need to do the following after upgrading:

rails g unread:polymorphic_reader_migration
rake db:migrate

This will alter the read_marks table to replace user association to a polymorphic association named reader. Therefore, user_id is going to be renamed to reader_id and reader_type is going to be added.

This change should not break your code unless you've worked with ReadMark model directly.

Defining reader_scope

The class method acts_as_reader doesn't take the option :scope anymore. If you have used it, please change this ...

class User < ActiveRecord::Base
  acts_as_reader scope: -> { where(is_admin: true) }
end

... to this

class User < ActiveRecord::Base
  acts_as_reader

  def self.reader_scope
    where(is_admin: true)
  end
end