hi, i have some nested resources like, a deal has_many :orders and has_one :invoice i am using nested routing for these. so the urls are like: deals_url deal_orders_url deal_invoice_url and others for the whole CRUD although everything is working perfectly, the updates for a nested resource are stuck. e.g. the edit page for an order comes up, buts submitting it gives me an error: Couldn''t find Order without an ID app/controllers/duties_controller.rb:92:in `get_order'' i have created a before_filter :get_deal def get_deal @deal = Deal.find(params[:deal_id]) end do i need to change something in my edit/update actions?? right now they are default ones generated after scaffolding. Regards -- Sahil --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You need to change the way you reference orders so that you scope an order within a deal. Give this a shot and let me know if it works: order_controller.rb: Index action: @order = @deal.orders.find(:all) Show action: @order = @deal.orders.find(params[:id]) New action: @order = @deal.orders.new Edit action: @order = @deal.orders.find(params[:id]) Create action: @order = @deal.orders.new(params[:order]) Update action: @order = @deal.orders.find(params[:id]) Delete action: @order = @deal.orders.find(params[:id]) On Wed, Feb 25, 2009 at 3:26 AM, Sahil Dave <sahil.dave19-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > > i have some nested resources like, a deal has_many :orders and has_one > :invoice > i am using nested routing for these. so the urls are like: > > deals_url > deal_orders_url > deal_invoice_url > > and others for the whole CRUD > > although everything is working perfectly, the updates for a nested resource > are stuck. e.g. the edit page for an order comes up, buts submitting it > gives me an error: > > Couldn''t find Order without an ID > app/controllers/duties_controller.rb:92:in `get_order'' > > i have created a before_filter :get_deal > > def get_deal > @deal = Deal.find(params[:deal_id]) > end > > do i need to change something in my edit/update actions?? right now they > are default ones generated after scaffolding. > > Regards > > -- > Sahil > > > >-- -Richard Aday --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 25, 11:23 pm, Richard Aday <richard.a...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You need to change the way you reference orders so that you scope an order > within a deal. >thank for the suggestion Richard.. but i managed to do it by adding an :except clause to the before filter to work on only new and edit --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---