我有一个用户模型与纸夹子为化身,我需要能够返回image_url的每一个大小(小,中,大)使用拉布尔。
在mongoid模型中,我只需要做self.avatar(:original),但是现在没有什么工作了,我只是在附件中得到了一个空的响应。
"user" : {
"id" : "50b204e10eae9c55fa000028",
"paperclip::attachment" : {},
"name" : "My Name"
}/models/user.rb
has_mongoid_attached_file :avatar,
:styles => {
:original => ['1000x1000>', :jpg],
:small => ['64x64#', :jpg],
:medium => ['250x250', :jpg],
:large => ['500x500>', :jpg]
}/views/posts/base.json.rabl
child :user do
attributes :id, :name
child :avatar do
attributes :original
end
end发布于 2012-12-02 19:55:12
试试这个:
child :user do
attributes :id, :name
node :avatar_original do |u|
u.avatar(:original)
end
endhttps://stackoverflow.com/questions/13659690
复制相似问题