我Picture
模型,可以包含2場照片和描述(照片是現場從papperclip寶石)軌form_helper找不到在編輯頁面模型路徑
,我有PicturesController
包含新創建編輯更新銷燬並顯示
我已申報routes.rb
使用resource :pictures
並且有我的路線。
pictures POST /pictures(.:format) pictures#create
new_pictures GET /pictures/new(.:format) pictures#new
edit_pictures GET /pictures/edit(.:format) pictures#edit
GET /pictures(.:format) pictures#show
PUT /pictures(.:format) pictures#update
DELETE /pictures(.:format) pictures#destroy
還有就是我的視圖代碼
# pictures/new.html.erb & pictures/edit.html.erb
<%= form_for @picture, :html => {:multipart => true} do |f| %>
<div><%= f.label :photo %><br/>
<%= f.file_field :photo %></div><br/>
<div><%= f.label :description %><br/>
<%= f.text_area :description %></div><br/>
<%= f.submit :upload %>
<% end %>
#
我使用新的和編輯只需更改提交按鈕標籤相同的代碼。
在new.html.erb
工作正常(創建並保存圖片到數據庫中)。
但錯誤是出現在edit.html.erb
undefined method `picture_path' for #<#<Class:0x007f830e93ad30>:0x007f830e92d5b8>
我已經檢查@picture
。爲什麼rails無法找到Picture類的更新路徑?
我按照這個link的form_for指導。
任何想法?謝謝。
請爲'new'和'edit'操作添加代碼。 – Thilo 2012-04-27 07:42:28
@Thilo問題出在我的路線上。謝謝你的答案。 :) – Rafaiel 2012-04-27 07:58:51