I cannot edit records for nested model. I have two models... Document
and Contentitem. Document has_many Contentitems.
The following link on the Document show page...
<%= link_to 'Edit', [@document, content], :method => :edit %>
Causes the following error...
No route matches "/documents/1/contentitems/9"
This is what I have... any ideas?
========= routes.rb ==============
Dg::Application.routes.draw do
root :to => "documents#index"
resources :templategroups do
resources :templateitems
end
resources :documents do
resources :contentitems
member do
put 'insert_into'
put 'sort'
end
end
end
========== contentitems_controller =======
class ContentitemsController < ApplicationController
before_filter :load_document
...
def edit
@contentitem = @document.contentitems.find(params[:contentitem])
end
...
private
def load_document
@document = Document.find(params[:document_id])
end
end