diff options
author | David Yip <yipdw@member.fsf.org> | 2018-04-14 03:50:31 -0500 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2018-04-14 03:50:31 -0500 |
commit | d66192f21c22dd79735a6c3ea6e2ed115b42e0d0 (patch) | |
tree | fec9f7eab346901c571c57023aa6231b0f855421 /app/models/bookmark.rb | |
parent | 78aca92689cd896f4be34daeb1852f75abc57472 (diff) | |
parent | 95a892accdb6a081447117f49c66431dc7e032fb (diff) |
Merge remote-tracking branch 'glitchsoc/master' into gs-master
Conflicts: db/schema.rb
Diffstat (limited to 'app/models/bookmark.rb')
-rw-r--r-- | app/models/bookmark.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb new file mode 100644 index 000000000..01dc48ee7 --- /dev/null +++ b/app/models/bookmark.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true +# == Schema Information +# +# Table name: bookmarks +# +# id :integer not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# status_id :integer not null +# + +class Bookmark < ApplicationRecord + include Paginable + + update_index('statuses#status', :status) if Chewy.enabled? + + belongs_to :account, inverse_of: :bookmarks + belongs_to :status, inverse_of: :bookmarks + + validates :status_id, uniqueness: { scope: :account_id } + + before_validation do + self.status = status.reblog if status&.reblog? + end +end |