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

Model generator gives confusing error when unknown type is specified

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: railsmdb
    • None

      The following happens with both railsmdb and rails, when ActiveRecord is not included:

       

      railsmdb generate model Score name:string value:number
      /Users/alex/.rvm/gems/ruby-3.1.2/gems/railties-7.0.8/lib/rails/generators/generated_attribute.rb:65:in `valid_type?': uninitialized constant #<Class:Rails::Generators::GeneratedAttribute>::ActiveRecord (NameError)
      
                  ActiveRecord::Base.connection.valid_type?(type)
                  ^^^^^^^^^^^^
      	from /Users/alex/.rvm/gems/ruby-3.1.2/gems/railties-7.0.8/lib/rails/generators/generated_attribute.rb:46:in `parse'
      	from /Users/alex/.rvm/gems/ruby-3.1.2/gems/railties-7.0.8/lib/rails/generators/named_base.rb:184:in `block in parse_attributes!'
      	from /Users/alex/.rvm/gems/ruby-3.1.2/gems/railties-7.0.8/lib/rails/generators/named_base.rb:183:in `map'
      	from /Users/alex/.rvm/gems/ruby-3.1.2/gems/railties-7.0.8/lib/rails/generators/named_base.rb:183:in `parse_attributes!'
      	from /Users/alex/.rvm/gems/ruby-3.1.2/gems/railties-7.0.8/lib/rails/generators/named_base.rb:17:in `initialize'
      	from /Users/alex/.rvm/gems/ruby-3.1.2/gems/thor-1.2.2/lib/thor/group.rb:226:in `new'
      	from /Users/alex/.rvm/gems/ruby-3.1.2/gems/thor-1.2.2/lib/thor/group.rb:226:in `dispatch'
      	from /Users/alex/.rvm/gems/ruby-3.1.2/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
      

      With railsmdb at least, we might be able to fix this by adding an alias for types like "number". More generally, it would be good to recognize when an unsupported type is given.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jamis.buck@mongodb.com Jamis Buck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: