mongoid/mongoid — Issue #1565: 2.4.0 no longer allows arbitrary foreign_key
Author: romanbsd
Created: 2012-01-08 11:03:59+00:00
State: open

This works in 2.3.4, but no longer in 2.4.0:

belongs_to :nas, :foreign_key => "NAS-Identifier"

/opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/fields.rb:358:in `class_eval': (eval):1: syntax error, unexpected '-', expecting ';' or '\n' (SyntaxError)
def NAS-Identifier
^
(eval):7: syntax error, unexpected keyword_end, expecting $end
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/fields.rb:358:in `block in create_accessors'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/fields.rb:342:in `module_eval'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/fields.rb:342:in `create_accessors'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/fields.rb:284:in `block in add_field'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/fields.rb:281:in `tap'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/fields.rb:281:in `add_field'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/fields.rb:191:in `field'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/relations/macros.rb:287:in `reference'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/relations/macros.rb:134:in `block in belongs_to'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/relations/macros.rb:132:in `tap'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.4.0/lib/mongoid/relations/macros.rb:132:in `belongs_to'