Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1566

2.4.0 no longer allows arbitrary foreign_key

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.4.1
    • Affects Version/s: None
    • Component/s: None

      This works in 2.3.4, but no longer in 2.4.0:

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

      <pre>
      /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'
      </pre>

            Assignee:
            Unassigned Unassigned
            Reporter:
            romanbsd Roman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: