开发者

trouble getting carrierwave to work

开发者 https://www.devze.com 2023-02-18 03:44 出处:网络
I am not sure if the image uploads just aren\'t saving or if I am saving them in the wrong place or what\'s wrong..right now when I generate the image tag with this code:

I am not sure if the image uploads just aren't saving or if I am saving them in the wrong place or what's wrong.. right now when I generate the image tag with this code:

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

it just throws a routing error:

No route matches "/images"

am I suppose to set up this route?.. I was following the tut on railscasts.org anyway here is some more relevant code:

<%= form.file_field :image %> #in the form

mount_uploader :image, Ima开发者_Python百科geUploader  #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


Ok here's how i fixed it.. I thought this was automatic, but it wasn't.

#in create method and update method and you good :]
@photo.image = params[:file]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号