RailsCasts Pro episodes are now free!

Learn more or hide this

Barry D'arcy's Profile

GitHub User: Darcbar

Comments by Barry D'arcy

Avatar

I think this can be resolved with default scopes? If you want your Picture to include :comments and your Spreadsheet to include :collaborators:

ruby
class Picture #model
  default_scope -> { includes(:comments).order('id DESC') }
end

class Spreadsheet #model
  default_scope -> { includes(:coolaborators).order('id DESC') }
end

... and if you didn't want to include somewhere, use something like Picture.all.unscoped