【发布时间】:2012-01-20 19:05:18
【问题描述】:
所以我按照这里的说明进行操作:http://doganberktas.com/2010/09/14/amazon-s3-and-paperclip-rails-3/
在我的个人资料模型中,我有:
attr_accessor :pic_file_name (this was requested on first attempt)
has_attached_file :pic,
:styles => {
:thumb=> "100x100#",
:small => "400x400>" },
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => "/:style/:id/:filename"
我的路线中有资源 :profiles。
我的观点如下:
<%= form_for :profile, @profile, :url => profile_path, :html => { :multipart => true } do |f| %>
<%= f.file_field :pic %>
<%= f.submit :class => "button-style", :value => "Upload File" %>
<% end %>
当我查看页面时,我收到此错误:没有路由匹配 {:action=>"show", :controller=>"profiles"}。虽然我可以向你保证,我有一个带有显示操作的配置文件控制器。
如果我将视图更改为
<%= form_for :profile, @profile, :url => @profile, :html => { :multipart => true } do |f| %>
<%= f.file_field :pic %>
<%= f.submit :class => "button-style", :value => "Upload File" %>
<% end %>
它告诉我我的参数数量错误(3 对 2)
如果我将视图更改为
<%= form_for @profile, :url => profile_path, :html => { :multipart => true } do |f| %>
<%= f.file_field :pic %>
<%= f.submit :class => "button-style", :value => "Upload File" %>
<% end %>
页面加载完毕,我可以上传图片。但是稍后尝试使用以下方法打印它:
给了我:/pics/original/missing.png(和 profile.pic.url 一样)
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 paperclip