Skip to content

Instantly share code, notes, and snippets.

@Hasstrup
Last active November 5, 2024 21:14
Show Gist options
  • Save Hasstrup/939727e85dbec4c0fa05737cf6110f62 to your computer and use it in GitHub Desktop.
Save Hasstrup/939727e85dbec4c0fa05737cf6110f62 to your computer and use it in GitHub Desktop.
class Templates::Component < ApplicationRecord
self.table_name = 'templates_components'
KEY_TYPE_APPLICATORS = {
invoices: %i[
issue_date
due_date
unit_price
total_hours
sub_total
total
]
}
belongs_to :template, class_name: 'Templates::Template'
validates :key_type, inclusion: { in: KEY_TYPE_APPLICATORS.values.flatten.map(&:to_s) }
end
# == Schema Information
#
# Table name: templates_components
#
# id :bigint not null, primary key
# key_tags :string is an Array
# key_type :string
# metadata :jsonb
# text_accessor :string
# title :string not null
# created_at :datetime not null
# updated_at :datetime not null
# template_id :bigint
#
# Indexes
#
# index_templates_components_on_template_id (template_id)
#
# Foreign Keys
#
# fk_rails_... (template_id => templates_templates.id)
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment