Answer the question
In order to leave comments, you need to log in
How to set default image in paperclip?
There is a user model.
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
has_many :posts, dependent: :destroy
has_many :comments, dependent: :destroy
has_attached_file :avatar, styles: { medium: "300x300>", thumb: "100x100>" },
default_url: "/images/:style/missing.png"
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
<p>
<strong>Avatar:</strong> <br>
<%= image_tag @user.avatar.url(:medium) %>
</p>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question