dm-aux_codes 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aux_codes.rb +5 -1
- metadata +1 -1
data/lib/aux_codes.rb
CHANGED
@@ -21,7 +21,7 @@ module Stuff
|
|
21
21
|
|
22
22
|
# timestamps :at
|
23
23
|
|
24
|
-
belongs_to :aux_code
|
24
|
+
belongs_to :aux_code
|
25
25
|
has n, :aux_codes
|
26
26
|
|
27
27
|
def self.name
|
@@ -208,6 +208,10 @@ module Stuff
|
|
208
208
|
# initialize AuxCodes ... looks for config/aux_codes.yml
|
209
209
|
# and creates classes
|
210
210
|
def init # should eventually take configuration options (hash || block)
|
211
|
+
# If there isn't an AuxCode yet, make one with the ID of 0.
|
212
|
+
# This makes database foreign key constraints stop complaining
|
213
|
+
# when we create aux codes where the aux_code_id is 0.
|
214
|
+
AuxCode.create :id => 0, :name => 'Aux Code Categories' if AuxCode.count == 0
|
211
215
|
aux_codes_yml = File.join 'config', 'aux_codes.yml'
|
212
216
|
if File.file? aux_codes_yml
|
213
217
|
load_file aux_codes_yml
|