0
이미지 업로드가 저장되지 않거나 잘못된 장소 또는 잘못된 곳에 저장하는 경우 확실하지 않습니다. 지금이 코드로 이미지 태그를 생성하면 바로 :반송파를 작동시키는 데 문제가 있습니다
<%= image_tag @photo.image_url.to_s %>
그냥 라우팅 오류가 발생합니다 :
No route matches "/images"
내가이 경로를 설정하는 가정 오전 .. 좀 더 관련 코드는 railscasts.org 어쨌든 여기에 혀를한다 다음되었습니다
<%= form.file_field :image %> #in the form
mount_uploader :image, ImageUploader #in the model Photo
#in the image_uploader file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
#also nothing special going on in the controller
def create
@photo = Photo.new(params[:photo])
respond_to do |format|
if @photo.save
format.html { redirect_to(@photo, :notice => 'Photo was successfully created.') }
format.xml { render :xml => @photo, :status => :created, :location => @photo }
else
format.html { render :action => "new" }
format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }
end
end
end
문제없이 개체가 생성됩니까? 그것은 단지 @ photos # show 오류를 던집니까? –
thats 정확하고 .to_s를 했으므로 런타임 오류가 표시되지 않지만 이미지가 nil 인 것처럼 보입니다. 그러나 링크를 만듭니다 ..../images/1823474 또는 w/e – Tyler