Created
March 12, 2015 17:23
-
-
Save ysinc88/9770f28c6d5a20a26b77 to your computer and use it in GitHub Desktop.
LED's associations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#How should one chain them ? Product > led_config > led | |
@products = Product.all | |
@ledconfig = LedConfiguration.all | |
@leds = Led.all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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