I have a problem displaying files accessible via my application. When a user logs in, I want to display all of their files. Files downloaded by current user should be displayed last. The file table has about 500 records, so I need simple and fast method to achieve this.
class User
has_many :downloads
has_many :downloaded_files, :through => :downloads, source: :file
end
class File
attr_accessor :downloaded
has_many :downloads
has_many :users, :through => :downloads
end
class Download
belongs_to :user
belongs_to :file
end
The technologies I am using
- Rails 4.2.1
- Ruby 2.2.2
- PostgreSQL