Skip to content

Commit

Permalink
Delay the definition of the associations until the table schema is lo…
Browse files Browse the repository at this point in the history
…aded

Closes delynn#4 and delynn#6.
  • Loading branch information
lowjoel committed Jan 30, 2017
1 parent 3354807 commit 4041960
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/active_record/userstamp/stampable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ module ActiveRecord::Userstamp::Stampable
end

module ClassMethods
def inherited(klass)
super
def columns(*)
columns = super
return columns if defined?(@stamper_initialized) && @stamper_initialized

klass.class_eval do
add_userstamp_associations({})
end
@stamper_initialized = true
add_userstamp_associations({})
columns
end

# This method customizes how the gem functions. For example:
Expand Down

0 comments on commit 4041960

Please sign in to comment.