사용자가 paperclip
gem으로 업로드 한 프로필 사진을 수정할 수있는 옵션을 추가하려고합니다. 그러나 인터넷에서 얻은 모든 예는 등록 된 적이없는 사용자를 등록하는 동안 이미지를 추가하는 방법을 설명합니다. 어떻게해야합니까? 나는 사용자 등록을 위해 장치를 사용하고 있습니다.사용자 가입 후 클립으로 이미지를 추가하는 방법은 무엇입니까?
def create
@user = User.where(id: current_user.id)
??
??
end
def user_params
params.require(:user).permit(:avatar)
end
우리가
User
모델에 이미지를 저장할 수 있도록 컨트롤러 액션
create
에 추가되어야 무엇
?
편집 : 기본 이미지가 표시되는 사용자 등록하면서
user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_attached_file :avatar, :styles => { :thumb => "59x59#" },, :default_url => "/images/:style/missing.jpg"
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
end
또한, 사용자 등록하면서 이미지를 선택하는 옵션이 없습니다.
사용자 모델의 코드를 제공해 주시겠습니까? 질문에 대답하는 사람에게 더 많은 컨텍스트를 추가합니다. –
@IleEftimov : 업데이트 됨 – InQusitive