Yes! Forks away!!!

On Sat, Dec 17, 2011 at 3:20 PM, Bruno Bornsztein
<[email protected]> wrote:
> Any chance you can send these (and your other changes) in a pull request
> with test cases? That would make it faster and easier for me to merge in.
>
>
> Thanks for helping!
>
> On Sat, Dec 17, 2011 at 5:02 PM, d00n <[email protected]> wrote:
>>
>> Hello all!
>>
>> In app/models/photo.rb, these Active Record calls:
>>
>>  def previous_photo
>>    self.user.photos.find(:first, :conditions => ['created_at < ?',
>> created_at], :order => 'created_at DESC')
>>  end
>>  def next_photo
>>    self.user.photos.find(:first, :conditions => ['created_at > ?',
>> created_at], :order => 'created_at ASC')
>>  end
>>
>>  def previous_in_album
>>    return nil unless self.album
>>    self.user.photos.find(:first, :conditions => ['created_at < ? and
>> album_id = ?', created_at, self.album.id], :order => 'created_at
>> DESC')
>>  end
>>  def next_in_album
>>    return nil unless self.album
>>    self.user.photos.find(:first, :conditions => ['created_at > ? and
>> album_id = ?', created_at, self.album_id], :order => 'created_at ASC')
>>  end
>>
>>
>> ..have their order params clobbered by an preceding 'order by
>> created_at DESC', which is inserted because of this association in the
>> user model:
>>
>> has_many :photos, :order => "created_at desc"
>>
>>
>> find(:first) is also deprecated. The fix:
>>
>>  def previous_photo
>>    self.user.photos.where('created_at < ?', created_at).first
>>  end
>>  def next_photo
>>    self.user.photos.where('created_at > ?', created_at).last
>>  end
>>
>>  def previous_in_album
>>    return nil unless self.album
>>    self.user.photos.where('created_at < ? and album_id = ?',
>> created_at, self.album.id).first
>>  end
>>  def next_in_album
>>    return nil unless self.album
>>    self.user.photos.where('created_at > ? and album_id = ?',
>> created_at, self.album_id).last
>>  end
>>
>>
>> Onward!
>> Mike
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "CommunityEngine" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/communityengine?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "CommunityEngine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/communityengine?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/communityengine?hl=en.

Reply via email to