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

Validation fails when I call MyObject.last.valid?

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

      Hi everybody,

      I have updated mongoid to version 2.1.2 and I have been seeing some issues, but one of them is very complicated. First of all I'll describe how my model is:

      class Person
        include Mongoid::Document
      
        validates_presence_of :game
        embeds_one :game, :inverse_of => :person
      end
      
      class Game 
        include Mongoid::Document
        embedded_in :person, :inverse_of => :game
      end
      

      I have created one person document:

      Unable to find source-code formatter for language: person. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      .create :game => Game.new 

      When I have called a validation in Person, likes follow:

      Unable to find source-code formatter for language: person. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      .last.valid? 

      I received "false" as result. This issue is broken some factories that I have in my project. Its possible to obtain a "true" result making something like this:

      Unable to find source-code formatter for language: person. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
       = Person.last
      person.game
      person.valid?
      

      But I think its must be a issue, is not it? Thanks for the great job.

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

              Created:
              Updated:
              Resolved: