Skip to content

Instantly share code, notes, and snippets.

@GAierken
Last active December 14, 2019 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GAierken/2395c05fc971cd4e2197484ffaf36df7 to your computer and use it in GitHub Desktop.
Save GAierken/2395c05fc971cd4e2197484ffaf36df7 to your computer and use it in GitHub Desktop.
app/models/slang.rb
class Slang < ApplicationRecord
belongs_to :user
has_many :definitions, dependent: :destroy
has_many :slang_books
has_many :books, through: :slang_books
accepts_nested_attributes_for :definitions, :reject_if => proc {|attributes|
attributes.all? {|k,v| v.blank?}}
validates :phrase, presence: true
validates :origin, presence: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment