Ruby on rails 3 轨道路由错误
我创建了一个名为folds的小应用程序,并为其指定了一些参数。我决定在每一个折叠中添加一张照片,并完成了一个关于回形针的教程 所以现在我已经安装了回形针和ImageMagick,当我编辑折叠时,我可以从硬盘上选择一个图像,当我点击更新折叠时,我得到一个路由错误,上面写着 路由错误Ruby on rails 3 轨道路由错误,ruby-on-rails-3,paperclip,rails-routing,Ruby On Rails 3,Paperclip,Rails Routing,我创建了一个名为folds的小应用程序,并为其指定了一些参数。我决定在每一个折叠中添加一张照片,并完成了一个关于回形针的教程 所以现在我已经安装了回形针和ImageMagick,当我编辑折叠时,我可以从硬盘上选择一个图像,当我点击更新折叠时,我得到一个路由错误,上面写着 路由错误 No route matches "/folds/2/edit" 我在这方面很新,所以我可以补充什么,让我得到一个明确的答案? 耙道 fold_comments GET /folds/:fold_id/comm
No route matches "/folds/2/edit"
我在这方面很新,所以我可以补充什么,让我得到一个明确的答案?
耙道
fold_comments GET /folds/:fold_id/comments(.:format) {:action=>"index", :controller=>"comments"}
fold_comments POST /folds/:fold_id/comments(.:format) {:action=>"create", :controller=>"comments"}
new_fold_comment GET /folds/:fold_id/comments/new(.:format) {:action=>"new", :controller=>"comments"}
edit_fold_comment GET /folds/:fold_id/comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"}
fold_comment GET /folds/:fold_id/comments/:id(.:format) {:action=>"show", :controller=>"comments"}
fold_comment PUT /folds/:fold_id/comments/:id(.:format) {:action=>"update", :controller=>"comments"}
fold_comment DELETE /folds/:fold_id/comments/:id(.:format) {:action=>"destroy", :controller=>"comments"}
folds GET /folds(.:format) {:action=>"index", :controller=>"folds"}
folds POST /folds(.:format) {:action=>"create", :controller=>"folds"}
new_fold GET /folds/new(.:format) {:action=>"new", :controller=>"folds"}
edit_fold GET /folds/:id/edit(.:format) {:action=>"edit", :controller=>"folds"}
fold GET /folds/:id(.:format) {:action=>"show", :controller=>"folds"}
fold PUT /folds/:id(.:format) {:action=>"update", :controller=>"folds"}
fold DELETE /folds/:id(.:format) {:action=>"destroy", :controller=>"folds"}
home_index GET /home/index(.:format) {:controller=>"home", :action=>"index"}
root /(.:format) {:controller=>"home", :action=>"index"}
fold.rb
class Fold < ActiveRecord::Base
validates :model, :presence => true
validates :folder, :presence => true
has_many :comments, :dependent => :destroy
has_attached_file :photo, :styles => { :small => "150x150>" },
:url => "/assets/folds/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/folds/:id/:style/:basename.:extension",
:dependent => :destroy
validates_attachment_presence :photo
validates_attachment_size :photo, :less_than => 5.megabytes
validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png']
end
_form.html.erb
<%= form_for :fold, :html => { :multipart => true } do |f| %>
<% if @fold.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@fold.errors.count, "error") %> prohibited this fold from being saved:</h2>
<ul>
<% @fold.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :model %><br />
<%= f.text_field :model %>
</div>
<div class="field">
<%= f.file_field :photo_file_name %>
</div>
<div class="field">
<%= f.label :folder %><br />
<%= f.text_field :folder %>
</div>
<div class="field">
<%= f.label :base %><br />
<%= f.text_field :base %>
</div>
<div class="field">
<%= f.label :creator %><br />
<%= f.text_field :creator %>
</div>
<div class="field">
<%= f.label :body %><br />
<%= f.text_area :body %>
</div>
<div class="field">
<%= f.label :fold_id %><br />
<%= f.text_field :fold_id %>
</div>
<div class="field">
<%= f.label :diagram %><br />
<%= f.text_field :diagram %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
{:multipart=>true}do | f |%>
禁止保存此折叠:
如果将视图的第一行更改为
<%= form_for @fold, :html => { :multipart => true } do |f| %>
{:multipart=>true}do | f |%>
改变
<%= f.file_field :photo_file_name %>
到
能否发布config/routes.rb
以及您从中获得此错误的视图?添加了,还有什么有用的吗?我得到了ActionController::RoutingError(没有路径匹配“/assets/folds/2/small”):但它不会破坏整个应用程序。该图像仍然没有得到上传,所以我有一个断开的链接。这是做什么的?这应该在编辑和创建操作中修复路由。至于为什么图像没有上传?我注意到另一件事(我会更新答案)。你的日志是怎么写的?回形针往往会给出非常详细的输出。
<%= f.file_field :photo_file_name %>
<%= f.file_field :photo %>