I was on /inventories/4000/orders/new page and click "submit" to create a new order before getting the error message.
On May 6, 5:45 pm, Mlle <[email protected]> wrote: > ok I made the change number 2. > > THis is the full trace: > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/ > recognition_optimisation.rb:64:in `recognize_path' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/ > route_set.rb:441:in `recognize' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/ > route_set.rb:436:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb: > 87:in `dispatch' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb: > 121:in `_call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb: > 130:in `build_middleware_stack' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb: > 29:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb: > 29:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/ > abstract/query_cache.rb:34:in `cache' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in > `cache' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb: > 28:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/ > abstract/connection_pool.rb:361:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ > string_coercion.rb:25:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb: > 15:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/ > cookie_store.rb:93:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in > `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb: > 114:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in > `run' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb: > 108:in `call' > /Users/e/.gem/ruby/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in > `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call' > /Users/e/.gem/ruby/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb: > 17:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run' > /Users/e/.gem/ruby/1.8/gems/rails-2.3.5/lib/commands/server.rb:111 > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > 1.8/rubygems/custom_require.rb:31:in `gem_original_require' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ > 1.8/rubygems/custom_require.rb:31:in `require' > > On May 6, 5:17 pm, Jens Fahnenbruck <[email protected]> wrote: > > > > > > > > > 1. can you post the full error message and what you did to get it > > 2. > > > def get_inventory > > @inventory = Inventory.find(params[:inventory_id]) > > end > > > should_be > > > def inventory > > @inventory ||= Inventory.find(params[:inventory_id]) > > end > > > the the Inventory is cached if you need it multiple time during one > > request. Leaving the `get_` is more like ruby and rails work on attribute > > accessors. And if you cache the inventory you can get rid of the @ in front > > of any other call to the inventory, just use the defined accessor method. > > > You can even get rid of the before filter if you use the `inventory` > > accessor, so the inventory only get's loaded if you really need it. > > On Freitag, 6. Mai 2011 at 23:11, Mlle wrote: > > hmm now I get Only get, put, and delete requests are allowed. > > > > This is in my routes: > > > > map.resources :inventories do |inventory| > > > inventory.resources :orders > > > end > > > map.resources :orders > > > > And this is my controller: > > > > before_filter :login_required, :get_inventory > > > > def new > > > @order = @inventory.orders.build > > > end > > > > def create > > > @order = @inventory.orders.build(params[:order]) > > > > if @order.save > > > flash[:success] = 'Order created successfully' > > > logger.debug "order saved successfully" > > > redirect_to @inventory > > > else > > > logger.debug "order not saved" > > > render :new > > > end > > > > end > > > > def get_inventory > > > @inventory = Inventory.find(params[:inventory_id]) > > > end > > > end > > > > On May 6, 4:59 pm, Jens Fahnenbruck <[email protected]> wrote: > > > > The routes description is different in rails 2.3.5 > > > > > map.resources :inventories do |inventory| > > > > inventory.resources :orders > > > > end > > > > > The rest should work as described. > > > > On Freitag, 6. Mai 2011 at 22:56, Mlle wrote: > > > > Oh, I should have mentioned that I'm using Rails 2.3.5. I'm not sure > > > > > > if that makes a difference? > > > > > I'll try out what you suggested, thanks! > > > > > > On May 6, 4:51 pm, Jens Fahnenbruck <[email protected]> wrote: > > > > > > @order = inventory.order.build(params[:order]) > > > > > > > should be > > > > > > > @order = inventory.orders.build(params[:order]) > > > > > > On Freitag, 6. Mai 2011 at 22:50, Jens Fahnenbruck wrote: > > > > > > I'm not sure if I understood you correctly. I assume you have a > > > > > > route like this: > > > > > > > > resources :inventories do > > > > > > > resources :orders > > > > > > > end > > > > > > > > If so you could use a before filter to automatically load the > > > > > > > inventory in your OrdersController before every action like this: > > > > > > > > class OrdersController < ApplicationController > > > > > > > def inventory > > > > > > > @inventory ||= Inventory.find(params[:inventory_id]) > > > > > > > end > > > > > > > before_filter :inventory > > > > > > > > def new > > > > > > > @order = inventory.orders.build > > > > > > > end > > > > > > > > def create > > > > > > > @order = inventory.order.build(params[:order]) > > > > > > > > if @order.save > > > > > > > flash[:success] = 'Order created successfully' > > > > > > > logger.debug " order saved successfully" > > > > > > > redirect_to inventory > > > > > > > else > > > > > > > logger.debug " order not saved" > > > > > > > render :new > > > > > > > end > > > > > > > end > > > > > > > end > > > > > > > > As you can see I simplified your > > ... > > read more » -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

