Ruby on rails 带导轨的回形针3.1路线错误
所以我遵循了这里的说明: 在我的个人资料模型中,我有:Ruby on rails 带导轨的回形针3.1路线错误,ruby-on-rails,ruby,ruby-on-rails-3,paperclip,Ruby On Rails,Ruby,Ruby On Rails 3,Paperclip,所以我遵循了这里的说明: 在我的个人资料模型中,我有: attr_accessor :pic_file_name (this was requested on first attempt) has_attached_file :pic, :styles => { :thumb=> "100x100#", :small => "400x400>" }, :storage => :s3, :s3_
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"
我的路线中有资源:配置文件
我的看法如下:
<%= 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 %>
profile_path,:html=>{:multipart=>true}do | f |%>
“按钮样式”,:值=>“上载文件”%>
当我查看页面时,我得到以下错误:没有路由匹配{: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 %>
@profile,:html=>{:multipart=>true}do | f |%>
“按钮样式”,:值=>“上载文件”%>
它告诉我我的参数数目不对(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 %>
profile_path,:html=>{:multipart=>true}do | f |%>
“按钮样式”,:值=>“上载文件”%>
页面加载后,我可以上传图像。但是,稍后尝试使用以下方式打印:
给我:/pics/original/missing.png(profile.pic.url也是如此)这似乎太愚蠢了(因为上面的内容以前对我有用)-但这解决了它:
将视图更改为:
<%= form_for(@profile, :html => { :multipart => true }) do |f| %>
{:multipart=>true})do | f |%>
谢谢您的解决方案。顺便说一下
<%= form_for (@profile, :html => { :multipart => true }) do |f| %>
{:multipart=>true})do | f |%>
不适合我,但是
<%= form_for(@profile, :html => { :multipart => true }) do |f| %>
{:multipart=>true})do | f |%>
确实有效。我在的
表单_之后的空间似乎破坏了一些东西,可能是我的问题的原因。这调用了m
,有两个参数:m(a,b)
。这是一个语法错误,因为括号将被视为将a,b
分组为单个(无效)表达式:m(a,b)
。