0

カスタムの '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 %>

私がやりたいことは、送信時にリリースコントローラーの更新アクションを使用することだけです。action => "update" を form_for タグに追加する単純なケースだと思いましたが、うまくいかないようです。エラーは発生しませんが、何も起こりません。

何が欠けているのか、どこが間違っているのか分かりますか?

リリースのレーキ ルートの出力:

      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"}
4

2 に答える 2

2

削除でき:action => 'update'ます。

デフォルトでは、永続化されたレコードはこのアクションに誘導されます

form_for(@release, :html => { :multipart => true }) do |f|
于 2012-05-14T14:51:19.543 に答える
0

action => "update"":url" 属性内にあるように変更してみてください:

:url => { :action => "update" }
于 2012-05-14T14:22:38.593 に答える