Created
May 7, 2013 19:11
-
-
Save aakashd/5535265 to your computer and use it in GitHub Desktop.
ActiveAdmin multi level has many configuration within Snacker
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 NutritionData < ActiveRecord::Base | |
attr_accessible :calories, :calories_from_fat, :header, :item_id, :serving, :nutrition_items_attributes | |
validates :calories, :presence => true, :numericality => true | |
validates :calories_from_fat, :presence => true, :numericality => true | |
validates :header, :presence => true | |
validates :serving, :presence => true | |
belongs_to :item | |
has_many :nutrition_items | |
accepts_nested_attributes_for :nutrition_items, :allow_destroy => true | |
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
class NutritionItem < ActiveRecord::Base | |
attr_accessible :nutrition_data_id, :title, :value, :child_nutrition_items_attributes | |
validates :title, :presence => true | |
validates :value, :presence => true | |
belongs_to :nutrition_data | |
belongs_to :parent, :class_name => 'NutritionItem' | |
has_many :child_nutrition_items, :class_name => 'NutritionItem', :foreign_key => :parent_id | |
accepts_nested_attributes_for :child_nutrition_items, :allow_destroy => true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment