← Back to Upcase

Rewrite scope using lambdas

(charlieanna) #1

How I rewrite these using lambdas to remove the deprecation warnings?

 default_scope include:[:room,:teacher,:subject]


 has_many :timetable_entries, dependent: :destroy, include: [:class_timing,:weekday,:small_group]

(Sean Griffin) #2
default_scope do
  includes(:room, :teacher, :subject)

(charlieanna) #3

and how about the latter one? I used this for the first one but could not convert the latter to lambda. Kept getting => type of errors.

default_scope -> { includes(:room).includes(:teacher).includes(:subject)}