我有一個自定義的'trackupload'視圖(這實際上只是我的編輯視圖中的變體)。路由表單更新操作?
def trackupload
@release = Release.find(params[:release_id]) #Note: I had to use :release_id instead of :id, not sure why?
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @release }
format.pdf { render :layout => false }
end
end
我的更新動作:
def update
@release = Release.find(params[:id])
respond_to do |format|
if @release.update_attributes(params[:release])
format.html { redirect_to @release, :notice => 'Release was successfully updated.' }
format.json { head :ok }
else
format.html { render :action => "edit" }
format.json { render :json => @release.errors, :status => :unprocessable_entity }
end
end
end
如下形式本身是:我用下面的控制器操作渲染這個
<%= form_for(@release, :action => "update", :html => { :multipart => true }) do |f| %>
<h3>Upload Tracks for <%= @release.title %></h3>
<%= f.fields_for :tracks do |builder| %>
<%= render 'upload_track_fields', :f => builder %>
<% end %>
<%= f.submit "Upload Tracks", :class => "submit" %>
<% end %>
所有我想這樣做使其在提交時使用釋放控制器的更新操作。我認爲這將是一個簡單的例子,爲我的form_for標記添加action =>「update」,但它似乎不起作用。我沒有錯,但沒有任何反應。
任何想法什麼是失蹤或我要去哪裏錯了?耙路線的用於發佈
輸出:
autocomplete_artist_name_releases GET /releases/autocomplete_artist_name(.:format) {:action=>"autocomplete_artist_name", :controller=>"releases"}
release_artists GET /releases/:release_id/artists(.:format) {:action=>"index", :controller=>"artists"}
POST /releases/:release_id/artists(.:format) {:action=>"create", :controller=>"artists"}
new_release_artist GET /releases/:release_id/artists/new(.:format) {:action=>"new", :controller=>"artists"}
edit_release_artist GET /releases/:release_id/artists/:id/edit(.:format) {:action=>"edit", :controller=>"artists"}
release_artist GET /releases/:release_id/artists/:id(.:format) {:action=>"show", :controller=>"artists"}
PUT /releases/:release_id/artists/:id(.:format) {:action=>"update", :controller=>"artists"}
DELETE /releases/:release_id/artists/:id(.:format) {:action=>"destroy", :controller=>"artists"}
release_tracks GET /releases/:release_id/tracks(.:format) {:action=>"index", :controller=>"tracks"}
POST /releases/:release_id/tracks(.:format) {:action=>"create", :controller=>"tracks"}
new_release_track GET /releases/:release_id/tracks/new(.:format) {:action=>"new", :controller=>"tracks"}
edit_release_track GET /releases/:release_id/tracks/:id/edit(.:format) {:action=>"edit", :controller=>"tracks"}
release_track GET /releases/:release_id/tracks/:id(.:format) {:action=>"show", :controller=>"tracks"}
PUT /releases/:release_id/tracks/:id(.:format) {:action=>"update", :controller=>"tracks"}
DELETE /releases/:release_id/tracks/:id(.:format) {:action=>"destroy", :controller=>"tracks"}
release_trackupload GET /releases/:release_id/trackupload(.:format) {:action=>"trackupload", :controller=>"releases"}
release_releases_tracks GET /releases/:release_id/releases_tracks(.:format) {:action=>"index", :controller=>"releases_tracks"}
POST /releases/:release_id/releases_tracks(.:format) {:action=>"create", :controller=>"releases_tracks"}
new_release_releases_track GET /releases/:release_id/releases_tracks/new(.:format) {:action=>"new", :controller=>"releases_tracks"}
edit_release_releases_track GET /releases/:release_id/releases_tracks/:id/edit(.:format) {:action=>"edit", :controller=>"releases_tracks"}
release_releases_track GET /releases/:release_id/releases_tracks/:id(.:format) {:action=>"show", :controller=>"releases_tracks"}
PUT /releases/:release_id/releases_tracks/:id(.:format) {:action=>"update", :controller=>"releases_tracks"}
DELETE /releases/:release_id/releases_tracks/:id(.:format) {:action=>"destroy", :controller=>"releases_tracks"}
release_product_tracks GET /releases/:release_id/products/:product_id/tracks(.:format) {:action=>"index", :controller=>"tracks"}
POST /releases/:release_id/products/:product_id/tracks(.:format) {:action=>"create", :controller=>"tracks"}
new_release_product_track GET /releases/:release_id/products/:product_id/tracks/new(.:format) {:action=>"new", :controller=>"tracks"}
edit_release_product_track GET /releases/:release_id/products/:product_id/tracks/:id/edit(.:format) {:action=>"edit", :controller=>"tracks"}
release_product_track GET /releases/:release_id/products/:product_id/tracks/:id(.:format) {:action=>"show", :controller=>"tracks"}
PUT /releases/:release_id/products/:product_id/tracks/:id(.:format) {:action=>"update", :controller=>"tracks"}
DELETE /releases/:release_id/products/:product_id/tracks/:id(.:format) {:action=>"destroy", :controller=>"tracks"}
release_product_producttracklistings GET /releases/:release_id/products/:product_id/producttracklistings(.:format) {:action=>"index", :controller=>"producttracklistings"}
POST /releases/:release_id/products/:product_id/producttracklistings(.:format) {:action=>"create", :controller=>"producttracklistings"}
new_release_product_producttracklisting GET /releases/:release_id/products/:product_id/producttracklistings/new(.:format) {:action=>"new", :controller=>"producttracklistings"}
edit_release_product_producttracklisting GET /releases/:release_id/products/:product_id/producttracklistings/:id/edit(.:format) {:action=>"edit", :controller=>"producttracklistings"}
release_product_producttracklisting GET /releases/:release_id/products/:product_id/producttracklistings/:id(.:format) {:action=>"show", :controller=>"producttracklistings"}
PUT /releases/:release_id/products/:product_id/producttracklistings/:id(.:format) {:action=>"update", :controller=>"producttracklistings"}
DELETE /releases/:release_id/products/:product_id/producttracklistings/:id(.:format) {:action=>"destroy", :controller=>"producttracklistings"}
release_product_itunes_data GET /releases/:release_id/products/:product_id/itunes_data(.:format) {:action=>"index", :controller=>"itunes_data"}
POST /releases/:release_id/products/:product_id/itunes_data(.:format) {:action=>"create", :controller=>"itunes_data"}
new_release_product_itunes_datum GET /releases/:release_id/products/:product_id/itunes_data/new(.:format) {:action=>"new", :controller=>"itunes_data"}
edit_release_product_itunes_datum GET /releases/:release_id/products/:product_id/itunes_data/:id/edit(.:format) {:action=>"edit", :controller=>"itunes_data"}
release_product_itunes_datum GET /releases/:release_id/products/:product_id/itunes_data/:id(.:format) {:action=>"show", :controller=>"itunes_data"}
PUT /releases/:release_id/products/:product_id/itunes_data/:id(.:format) {:action=>"update", :controller=>"itunes_data"}
DELETE /releases/:release_id/products/:product_id/itunes_data/:id(.:format) {:action=>"destroy", :controller=>"itunes_data"}
release_products GET /releases/:release_id/products(.:format) {:action=>"index", :controller=>"products"}
POST /releases/:release_id/products(.:format) {:action=>"create", :controller=>"products"}
new_release_product GET /releases/:release_id/products/new(.:format) {:action=>"new", :controller=>"products"}
edit_release_product GET /releases/:release_id/products/:id/edit(.:format) {:action=>"edit", :controller=>"products"}
release_product GET /releases/:release_id/products/:id(.:format) {:action=>"show", :controller=>"products"}
PUT /releases/:release_id/products/:id(.:format) {:action=>"update", :controller=>"products"}
DELETE /releases/:release_id/products/:id(.:format) {:action=>"destroy", :controller=>"products"}
releases GET /releases(.:format) {:action=>"index", :controller=>"releases"}
POST /releases(.:format) {:action=>"create", :controller=>"releases"}
new_release GET /releases/new(.:format) {:action=>"new", :controller=>"releases"}
edit_release GET /releases/:id/edit(.:format) {:action=>"edit", :controller=>"releases"}
release GET /releases/:id(.:format) {:action=>"show", :controller=>"releases"}
PUT /releases/:id(.:format) {:action=>"update", :controller=>"releases"}
DELETE /releases/:id(.:format) {:action=>"destroy", :controller=>"releases"}
我想我原本是這樣做的,但現在這個表單現在可以正確呈現,但是在提交時沒有我所做的更改都會被處理,所以我只能假定它沒有指向更新操作。儘管如此,我被帶回來顯示提交!??! – Raoot
***這應該說「不處理」 – Raoot
它指向更新操作!作爲一個測試,我介紹了一些我知道會產生錯誤的操作....所以這只是一個沒有更新的值。 – Raoot