Revision 3c4051e9
Added by Joseph Magen about 10 years ago
app/models/concerns/taxonomix.rb | ||
---|---|---|
|
||
def set_current_taxonomy
|
||
if self.new_record? && self.errors.empty?
|
||
self.id = nil #fix for rails 3.2.8 bug that sets id = 1 on after_initialize. This can later be removed.
|
||
self.locations << Location.current if add_current_location?
|
||
self.organizations << Organization.current if add_current_organization?
|
||
end
|
test/unit/taxonomix_test.rb | ||
---|---|---|
require 'test_helper'
|
||
|
||
class TaxonomixDummy < ActiveRecord::Base
|
||
self.table_name = 'environments'
|
||
include Taxonomix
|
||
|
||
attr_accessor :locations, :organizations
|
||
after_initialize :set_taxonomies_to_empty
|
||
|
||
def new_record?
|
||
true
|
||
end
|
||
|
||
def errors
|
||
OpenStruct.new :empty? => true
|
||
end
|
||
|
||
def initialize
|
||
def set_taxonomies_to_empty
|
||
self.locations = []
|
||
self.organizations = []
|
||
end
|
Also available in: Unified diff
fixes #4731 - Rails 3.2.8 causing _pkey constraint errors