Is there a proper way to write this, or am I approaching this wrong? I need to do a nested include. I found This Link but it doesn’t seem to work.
def show
@showring = Ring.includes(:stones => :upcharges, :variations).find(params[:id])
end
I have 3 tables…
Rings which has_many stones
Stones which has_many upcharges
Models:
class Ring < ActiveRecord::Base
has_many :stones
end
class Stone < ActiveRecord::Base
has_many :upcharges
belongs_to :ring
end
class Upcharge < ActiveRecord::Base
belongs_to :stone
end
Added some brackets 🙂
Getting all upcharges :
Option 2 : Declare a
has_many :throughThen in the view :