下面是我的代码:
class Profile < ActiveRecord::Base
belongs_to :user
validates :first_name, presence: true
validates :last_name, presence: true
has_attached_file :avatar,
:styles => { :medium => "300x300>", :thumb => "100x100>" },
:default_url => ":style/missing.jpg"
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
end
另外,我的图像作为missing.jpg 存储在app/assets/images/medium 中,作为missing.jpg 存储在app/assets/images/thumbs 中。现在我得到的错误是它只显示单词缺失而没有图片。
下面是在我的视图文件中显示图片的代码。
<div class="profile-image">
<%= image_tag @user.profile.avatar.url %>
</div>
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)