railscast 198 http://railscasts.com/episodes/198-edit-multiple-individuallyに従っており、レール3に更新しようとしていて、ルーティングエラーが発生しています。ルートhttp://localhost:3000/orders/edit_individualは私にエラーを与える:(私のニーズに更新)engineyard http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/複数のレコードとコントローラとルーティングを編集する
によって記載されているようにActiveRecord::RecordNotFound in OrdersController#show - Couldn't find Order with ID=edit_individual
私は更新され、レール3大会に
map.resources :products, :collection => { :edit_individual => :post, :update_individual => :put }
をルーティング彼のレール2を使用していました
resources :orders do
collection do
post :edit_individual
put :update_individual
end
end
私が試したことは次のとおりです。
私は答えに示唆されるように経路のリソースを変更しようとしました:Adding an action to an existing controller (Ruby on Rails)しかし、同じエラーがまだ表示されます。 cancanの読み込みを取り除き、リソース、すなわちリソース:ordersのルートエントリとコントローラの 'show'エントリを認可しようとしましたが、ID = 'edit_individual'のレコードを表示しようとしているという別のエラーがあることを示しています。ルートのように "edit_individual"を扱う代わりに。ここで
は
myapp::Application.routes.draw do
resources :products
resources :roles
devise_for :users #, :controllers => { :registrations => "registrations" }
# match 'dashboard' => 'user_dashboard#index', :as => 'user_root'
resources :orders do
collection do
post :edit_individual
put :update_individual
end
end
resources :orders
class OrdersController < ApplicationController
load_and_authorize_resource # cancan method
def index
end
def show
end
def edit_individual #from railscast 198
@orders = current_user.customer_orders
end
def update_individual
@orders = Order.update(params[:orders].keys, params[:orders].values).reject { |p| p.errors.empty? }
if @orders.empty?
flash[:notice] = "Orders updated"
redirect_to orders_url
else
render :action => "edit_individual"
end
end # ...etc.
、私のルートとコントローラです私はカンカンメソッドを削除したが、それはまだ犯人のですか?私は考えることができるすべてを試して、枯れたところにいます..どんなアイデアですか?
編集:
コマンドプロンプトからの出力:
Started GET "/orders/edit_individual" for 127.0.0.1 at Thu Jun 30 11:19:02 -0700
2011
Processing by OrdersController#show as HTML
Parameters: {"id"=>"edit_individual"}
←[1m←[36mOrder Load (0.0ms)←[0m ←[1mSELECT "orders".* FROM "orders" WHERE "or
ders"."id" = 0 LIMIT 1←[0m
Completed in 2584ms
ActiveRecord::RecordNotFound (Couldn't find Order with ID=edit_individual):
と私のhtmlでのルート:
<%= link_to 'Update Payments Received', edit_individual_orders_path %>
と熊手路線:だから
edit_individual_orders POST /orders/edit_individual(.:format) {:action=>"edit_individual", :controller=>"orders"}
update_individual_orders PUT /orders/update_individual(.:format) {:action=>"update_individual", :controller=>"orders"}
orders GET /orders(.:format) {:action=>"index", :controller=>"orders"}
POST /orders(.:format) {:action=>"create", :controller=>"orders"}
new_order GET /orders/new(.:format) {:action=>"new", :controller=>"orders"}
edit_order GET /orders/:id/edit(.:format) {:action=>"edit", :controller=>"orders"}
order GET /orders/:id(.:format) {:action=>"show", :controller=>"orders"}
PUT /orders/:id(.:format) {:action=>"update", :controller=>"orders"}
DELETE /orders/:id(.:format) {:action=>"destroy", :controller=>"orders"}
はい、ありがとうございます。レーキルートのために投稿した編集を見てください。 – thejonster
私はあなたのエラーを受けました。私の更新された答えを見てください。 – MKumar
このエラーは解決しましたか? – MKumar