Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9640: fix_nested_includes2.patch

File fix_nested_includes2.patch, 1.3 kB (added by blweiner, 4 months ago)
  • avatar.rb

    old new  
     1class Avatar < ActiveRecord::Base 
     2   
     3  belongs_to :picture 
     4   
     5end 
  • developer.rb

    old new  
    4242  has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id' 
    4343 
    4444  has_many :audit_logs 
     45   
     46  has_one :picture 
    4547 
    4648  validates_inclusion_of :salary, :in => 50000..200000 
    4749  validates_length_of    :name, :within => 3..20 
  • picture.rb

    old new  
     1class Picture < ActiveRecord::Base 
     2   
     3  has_one :large_avatar, :class_name => 'Avatar', :conditions => { :thumbnail => 'large' }, :dependent => :destroy 
     4  has_one :small_avatar, :class_name => 'Avatar', :conditions => { :thumbnail => 'small' }, :dependent => :destroy 
     5  belongs_to :developer 
     6    
     7  def after_create 
     8    create_large_avatar :filename => "large_#{self.filename}", :thumbnail => 'large' 
     9    create_small_avatar :filename => "small_#{self.filename}", :thumbnail => 'small' 
     10  end 
     11   
     12end