Skip to content

Instantly share code, notes, and snippets.

@nicedawg

nicedawg/user.rb Secret

Created February 14, 2020 01:15
Show Gist options
  • Save nicedawg/23d2377fd1ac4d87c992acc341c6b8ad to your computer and use it in GitHub Desktop.
Save nicedawg/23d2377fd1ac4d87c992acc341c6b8ad to your computer and use it in GitHub Desktop.
[Beginning Rails 6] Listing 6-18. The Updated User Model, has_many :through Declarations in app/models/user.rb
class User < ApplicationRecord
has_one :profile
has_many :articles, -> { order 'published_at DESC, title ASC' },
dependent: :nullify
has_many :replies, through: :articles, source: :comments
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment