Skip to content

Instantly share code, notes, and snippets.

@ysinc88
Created March 12, 2015 17:23
Show Gist options
  • Save ysinc88/9770f28c6d5a20a26b77 to your computer and use it in GitHub Desktop.
Save ysinc88/9770f28c6d5a20a26b77 to your computer and use it in GitHub Desktop.
LED's associations
#How should one chain them ? Product > led_config > led
@products = Product.all
@ledconfig = LedConfiguration.all
@leds = Led.all
class Product < ActiveRecord::Base
has_many :led_configurations
has_many :leds, through: :led_configurations
end
class LedConfiguration < ActiveRecord::Base
belongs_to :product
has_many :leds
end
class Led < ActiveRecord::Base
belongs_to :led_configurations
end
<td>
<% @leds.each do |l| %>
<%= l.wl %>
<% end %>
</td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment