Hi Sean,
Actually I've this already for a different nested structure. The
problem is that I'm not able to replicate the same behavior with my
webnews.
This is the structure page->info->content:
Controllers:
class PagesController < ResourceController::Base
actions :all, :except => [:new, :edit, :create, :update, :destroy]
end
class InfosController < ResourceController::Base
belongs_to :page
actions :all, :except => [:new, :edit, :create, :update, :destroy]
end
class ContentsController < ResourceController::Base
belongs_to [:page, :info], [:webnew, :article]
actions :all, :except => [:new, :edit, :create, :update, :destroy]
end
These controllers are working fine (and you can see that I have
already an association for my new structure for the Contents
Controller)
The same should be working with webnew->article->content:
class WebnewsController < ResourceController::Base
actions :all, :except => [:new, :edit, :create, :update, :destroy]
end
class ArticlesController < ResourceController::Base
belongs_to :webnew
actions :all, :except => [:new, :edit, :create, :update, :destroy]
end
Additionally the models are:
class Page < ActiveRecord::Base
has_many :infos
validates_presence_of :name, :title
...
end
class Info < ActiveRecord::Base
belongs_to :page
has_many :contents, :as => :content
end
class Content < ActiveRecord::Base
belongs_to :content, :polymorphic => true
end
class Webnew < ActiveRecord::Base
has_many :articles
...
end
class Article < ActiveRecord::Base
belongs_to :webnew
has_many :contents, :as => :content
end
In the end, the routing should be:
# Pages
map.resources :pages do |page|
page.resources :infos, :has_many => :contents
end
# Webnews
map.resources :webnews do |webnew|
webnew.resources :articles, :has_many => :contents
end
Am I thinking wrongly?
Thank you..
David