0

画像のアップロードが保存されていないだけなのか、間違った場所に保存しているのか、何が問題なのかわかりません..今、このコードで画像タグを生成すると:

<%= image_tag @photo.image_url.to_s %>

ルーティングエラーをスローするだけです:

No route matches "/images"

私はこのルートを設定すると思いますか?..私は railscasts.org の tut に従っていました。

<%= 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
4

1 に答える 1