Ruby on rails 回形针图像未保存在路径i';我已经建立了
我尝试将我用回形针上传的图像保存到特定路径。 我希望图像保存在RubyonRails应用程序中的app/assets/image dir中,但它们似乎不在其中 这是config/environments/development.rb中的路径Ruby on rails 回形针图像未保存在路径i';我已经建立了,ruby-on-rails,url,path,paperclip,Ruby On Rails,Url,Path,Paperclip,我尝试将我用回形针上传的图像保存到特定路径。 我希望图像保存在RubyonRails应用程序中的app/assets/image dir中,但它们似乎不在其中 这是config/environments/development.rb中的路径 config.paperclip_defaults = { :url => ":rails_root/app/assets/images/:attachment/:id/:style/:filename", :path => "/:cl
config.paperclip_defaults = {
:url => ":rails_root/app/assets/images/:attachment/:id/:style/:filename",
:path => "/:class/:attachment/:id/:style/:basename.:extension"
}
我真的很感激你能给我的任何建议或帮助,如果你想要更多的信息,我会尽快把它贴出来
这是从产品图片创建的def,显示了我如何创建图片并保存它
def create
@product_image = ProductImage.new(params[:product_image])
@product = @product_image.product
if @product_image.save
@product.product_image_id = @product_image.id
@product.save
redirect_to @product_image, notice: 'Product image was successfully created.'
else
render :template => "products/edit"
end
end
在访问回形针的模型中,将此代码放在回形针中,而不是放在development.rb文件中
has_attached_file :model_name,
:path => ":attachment/:id/:style/:basename.:extension"
我看不到图像目录有任何变化。我将添加def create p[art of the controller here,以便您可以查看图像是否正确保存。这有点复杂,因为产品图像属于产品。我只是重新阅读了您的问题并思考了一下。Rails将图像放入公用文件夹,因此如果您要保存图像,可以在公用文件夹中创建一个图像文件夹因此,我使用AmazonS3。