在 Rails 2.3.6 中我有一个用户模型:
class User < ActiveRecord::Base
has_attached_file :avatar,
:styles => {
:micro => "32x32#",
:thumb => "50x50#",
:big_thumb => "80x80#",
:small => "220x220>",
:featured => "220x220#",
:medium => "600x600>"
}
end
如何在用户模型中搜索具有附加头像的用户?
最佳答案
假设您有一个关于用户的名为“avatar_file_name”的列
User.scoped({:conditions => 'avatar_file_name IS NOT NULL'})
应该这样做
关于ruby-on-rails - 回形针和 ActiveRecord : search for objects with attached files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7756270/