How can I limit the number of rows returned in a has many relationship? For example:
class User < ActiveRecord::Base
has_many :photos
end
Just add a limit option to the has_many association:
class User < ActiveRecord::Base
has_many :photos, :limit => 8
end
EDIT
According to your needs:
class User < ActiveRecord::Base
has_many :all_photos, :class_name => "Photo"
has_many :photos, :limit => 8
end
note: changed 'class' to 'class_name' in the all_photos association