mirror of
https://github.com/wahyd4/libr-2.git
synced 2026-08-09 05:15:53 +10:00
#40 Add model soft delete
This commit is contained in:
@@ -83,6 +83,7 @@ gem 'font-awesome-rails', '~> 4.4'
|
||||
#gem 'sprockets-es6'
|
||||
|
||||
gem "sentry-raven" #, :github => "getsentry/raven-ruby"
|
||||
gem "paranoia", "~> 2.0"
|
||||
|
||||
group :development do
|
||||
gem 'capistrano'
|
||||
|
||||
@@ -238,6 +238,8 @@ GEM
|
||||
mimemagic (= 0.3.0)
|
||||
paperclip-meta (1.2.0)
|
||||
paperclip (>= 3.0.2, < 5.0)
|
||||
paranoia (2.1.4)
|
||||
activerecord (~> 4.0)
|
||||
pg (0.18.3)
|
||||
polyamorous (1.2.0)
|
||||
activerecord (>= 3.0)
|
||||
@@ -431,6 +433,7 @@ DEPENDENCIES
|
||||
paperclip (~> 4.0)
|
||||
paperclip-meta
|
||||
paperclip-qiniu!
|
||||
paranoia (~> 2.0)
|
||||
pg
|
||||
pry
|
||||
puma
|
||||
|
||||
+3
-1
@@ -3,13 +3,15 @@ class Post < ActiveRecord::Base
|
||||
has_many :comments, as: :commentable
|
||||
has_many :likes, as: :likable
|
||||
has_many :favorites, as: :favoritable
|
||||
has_many :share_instances, as: :sharable
|
||||
has_many :share_instances, as: :sharable, dependent: :destroy
|
||||
has_many :timeline_sources
|
||||
|
||||
has_one :thumbnail
|
||||
|
||||
validates_presence_of :url, :type
|
||||
|
||||
acts_as_paranoid
|
||||
|
||||
# default_scope { order(:created_at => :desc) }
|
||||
|
||||
def first_sharer
|
||||
|
||||
@@ -4,4 +4,6 @@ class ShareInstance < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
delegate :name, to: :user, prefix: true
|
||||
|
||||
acts_as_paranoid
|
||||
end
|
||||
|
||||
@@ -21,6 +21,7 @@ class User < ActiveRecord::Base
|
||||
has_one :avatar
|
||||
has_one :identity
|
||||
|
||||
acts_as_paranoid
|
||||
|
||||
def followers
|
||||
user_ids = FollowRelation.where(star_id: self.id).pluck(:user_id)
|
||||
|
||||
+9
-1
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20151110094635) do
|
||||
ActiveRecord::Schema.define(version: 20151123161926) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -144,8 +144,11 @@ ActiveRecord::Schema.define(version: 20151110094635) do
|
||||
t.integer "comments_count", default: 0
|
||||
t.string "summary"
|
||||
t.integer "bookmarks_count", default: 0
|
||||
t.datetime "deleted_at"
|
||||
end
|
||||
|
||||
add_index "posts", ["deleted_at"], name: "index_posts_on_deleted_at", using: :btree
|
||||
|
||||
create_table "share_instances", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "sharable_id"
|
||||
@@ -153,8 +156,11 @@ ActiveRecord::Schema.define(version: 20151110094635) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "description"
|
||||
t.datetime "deleted_at"
|
||||
end
|
||||
|
||||
add_index "share_instances", ["deleted_at"], name: "index_share_instances_on_deleted_at", using: :btree
|
||||
|
||||
create_table "thumbnails", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
@@ -190,8 +196,10 @@ ActiveRecord::Schema.define(version: 20151110094635) do
|
||||
t.datetime "last_sign_in_at"
|
||||
t.inet "current_sign_in_ip"
|
||||
t.inet "last_sign_in_ip"
|
||||
t.datetime "deleted_at"
|
||||
end
|
||||
|
||||
add_index "users", ["deleted_at"], name: "index_users_on_deleted_at", using: :btree
|
||||
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
||||
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
||||
|
||||
|
||||
@@ -5,3 +5,4 @@
|
||||
#
|
||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||
AdminUser.create!(email: 'admin@librme.com', password: 'password1', password_confirmation: 'password1')
|
||||
|
||||
Reference in New Issue
Block a user