diff --git a/app/serializers/collection_serializer.rb b/app/serializers/collection_serializer.rb index 6df8b10ccd32c6d01dc33371e5284fe073100cea..36904b88abb280581edc8d255e5c904109409d67 100644 --- a/app/serializers/collection_serializer.rb +++ b/app/serializers/collection_serializer.rb @@ -13,7 +13,8 @@ class CollectionSerializer < ActiveModel::Serializer object.complained? current_user end - attributes :id, :name, :owner, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :liked, :reviewed, :complained, :review_average, :thumbnail + attributes :id, :name, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :liked, :reviewed, :complained, :review_average, :thumbnail + belongs_to :owner has_many :tags has_many :subjects has_many :educational_stages diff --git a/db/migrate/20170109133754_add_nickname_to_user.rb b/db/migrate/20170109133754_add_nickname_to_user.rb new file mode 100644 index 0000000000000000000000000000000000000000..37f4c21bdfc000abe35e91e9893185c58418b155 --- /dev/null +++ b/db/migrate/20170109133754_add_nickname_to_user.rb @@ -0,0 +1,5 @@ +class AddNicknameToUser < ActiveRecord::Migration[5.0] + def change + add_column :users, :nickname, :string + end +end diff --git a/lib/tasks/attachment_maintaining_service.rake b/lib/tasks/attachment_maintaining_service.rake new file mode 100644 index 0000000000000000000000000000000000000000..6587edd4c8c5d01ee8f47c379fdbe34b4b06925d --- /dev/null +++ b/lib/tasks/attachment_maintaining_service.rake @@ -0,0 +1,25 @@ +require 'fileutils' + + namespace :attachment_maintaining_service do + desc 'Removing 10 attachments' + task remove_attachments: :environment do + m = sort_directories.first(10) + m.each do |mm| + #puts (mm) + FileUtils.rm_r(mm) + end + end + + def sort_directories + files_sorted_by_time = Dir[dir_path].sort_by{ |f| File.atime(f) } + files_sorted_by_time + end + + private + + def dir_path + c = Rails.root.join('public','attachments','*').to_s + c + end + + end