Last active
June 26, 2019 17:22
-
-
Save staycreativedesign/2c04904463f7e54490c28cb68331594d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<div class="nested-categories nested-group"> | |
<%= f.semantic_fields_for :trade_categories, builder: Formtastic::FormBuilder do |trade_categories| %> | |
<%= render 'trade_categories/trade_category_fields', trade_categories: trade_categories %> | |
<% end %> | |
</div> |
This file contains hidden or 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
<div class="nested-category"> | |
<%= render 'shared/nested_semantic_errors', f: trade_categories %> | |
<%= trade_categories.input :trade_category_type, label: false, input_html: { class: 'form-control', placeholder: t('trade_category_type') }, wrapper_html: { class: 'category-name' } %> | |
<div class="nested-options"> | |
<%= trade_categories.semantic_fields_for :trade_options, builder: Formtastic::FormBuilder do |trade_options| %> | |
<ul> | |
<%= render 'trade_categories/trade_option_fields', trade_options: trade_options %> | |
</ul> | |
<% end %> | |
</div> | |
<div class="clearfix"> | |
<%= link_to_add_association t('add_option'), trade_categories, :trade_options, class: 'btn btn-primary pull-right add-option' %> | |
<%= link_to_remove_association t('remove_category'), trade_categories, class: 'btn btn-danger', wrapper_class: 'nested-category' %> | |
</div> | |
</div> |
This file contains hidden or 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 TradeCategoryType < ApplicationRecord | |
include Accountable | |
has_many :trade_categories, dependent: :restrict_with_exception | |
has_many :crew_trade_categories, dependent: :restrict_with_exception | |
has_many :subcontractor_crews, through: :crew_trade_categories | |
scope :collection, (-> { all.collect { |sub| [sub.name, sub.id] } }) | |
end |
This file contains hidden or 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 TradeOption < ApplicationRecord | |
include Accountable | |
default_scope { order(name: :asc) } | |
validates :name, presence: true | |
belongs_to :trade_category, touch: true | |
has_many :trade_data, as: :trade_data_parent | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment