Skip to content

bowsersenior/test_association_extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

== Bug with Association Extensions when used together with named_scope

https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1221-association-extensions-and-scopes-on-the-associated-model-behave-inconsistantly#ticket-1221-4

An example:
  >> Rails.version
  "2.3.8"
  >> b = Blog.first
  #<Blog:0x2397edc> {
              :id => 1,
      :created_at => Thu, 19 Aug 2010 19:36:44 UTC +00:00,
      :updated_at => Thu, 19 Aug 2010 19:36:44 UTC +00:00
  }
  >> b.entries
  [
      [0] #<Entry:0x23767b4> {
                  :id => 1,
              :status => "active",
             :blog_id => 1,
          :created_at => Thu, 19 Aug 2010 19:37:02 UTC +00:00,
          :updated_at => Thu, 19 Aug 2010 19:37:02 UTC +00:00
      },
      [1] #<Entry:0x2376750> {
                  :id => 2,
              :status => "active",
             :blog_id => 1,
          :created_at => Thu, 19 Aug 2010 19:37:04 UTC +00:00,
          :updated_at => Thu, 19 Aug 2010 19:37:04 UTC +00:00
      },
      [2] #<Entry:0x2376700> {
                  :id => 3,
              :status => "inactive",
             :blog_id => 1,
          :created_at => Thu, 19 Aug 2010 19:37:06 UTC +00:00,
          :updated_at => Thu, 19 Aug 2010 19:37:06 UTC +00:00
      }
  ]
  >> b.entries.active.print
  active
  active
  inactive  # this shouldn't be here!
  nil
  >> Blog.first.entries.active.print
  active
  active
  nil
  >> Blog.first.entries.inactive.print
  inactive
  nil
  
  
Another example:
  >> c = Blog.first
  #<Blog:0x237af58> {
              :id => 1,
      :created_at => Thu, 19 Aug 2010 19:36:44 UTC +00:00,
      :updated_at => Thu, 19 Aug 2010 19:36:44 UTC +00:00
  }
  >> c.entries.inactive
  [
      [0] #<Entry:0x2374a54> {
                  :id => 3,
              :status => "inactive",
             :blog_id => 1,
          :created_at => Thu, 19 Aug 2010 19:37:06 UTC +00:00,
          :updated_at => Thu, 19 Aug 2010 19:37:06 UTC +00:00
      }
  ]
  >> c.entries.inactive.print
  inactive
  nil
  >> c.entries.print
  inactive
  nil
  >> c.entries
  [
      [0] #<Entry:0x236ccdc> {
                  :id => 3,
              :status => "inactive",
             :blog_id => 1,
          :created_at => Thu, 19 Aug 2010 19:37:06 UTC +00:00,
          :updated_at => Thu, 19 Aug 2010 19:37:06 UTC +00:00
      }
  ]
  >> Blog.first.entries
  [
      [0] #<Entry:0x2363f10> {
                  :id => 1,
              :status => "active",
             :blog_id => 1,
          :created_at => Thu, 19 Aug 2010 19:37:02 UTC +00:00,
          :updated_at => Thu, 19 Aug 2010 19:37:02 UTC +00:00
      },
      [1] #<Entry:0x2363ec0> {
                  :id => 2,
              :status => "active",
             :blog_id => 1,
          :created_at => Thu, 19 Aug 2010 19:37:04 UTC +00:00,
          :updated_at => Thu, 19 Aug 2010 19:37:04 UTC +00:00
      },
      [2] #<Entry:0x2363e70> {
                  :id => 3,
              :status => "inactive",
             :blog_id => 1,
          :created_at => Thu, 19 Aug 2010 19:37:06 UTC +00:00,
          :updated_at => Thu, 19 Aug 2010 19:37:06 UTC +00:00
      }
  ]

About

A blank rails project to help debug a possible bug with ActiveRecord Association extensions when used together with named_scopes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published