Я не уверен, что загруженные изображения просто не сохраняются или я сохраняю их не в том месте или что-то не так ... прямо сейчас, когда я генерирую тег изображения с этим кодом:
<%= 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