Hi All,
I’m have this domain model:
a page has many areas which has many elements.
I’m generating a page by generating it’s areas which in turn generate
the elements.
the problem is that currently the page show action generates the layout
and then render the different partials for each area. the area render
the diffrent elements buy all of the partials are in the view/page
directory.
how can i separate the responsibilities between the object so that each
object will know the render it self ? should i just move the partials to
another directory and render from there ? how ?
Thank you
here’s my code :
page.rhtml :
_area.rhtml :
<%area = @page.areas.find_by_name(name)
if area.overide==true then
mainpage = Page.find(@page.site.mainid)
area = mainpage.areas.find_by_name(name)%>
<%=“ovvver”%>
<%end
elements = area.elements.sort{ |x,y| x.position <=> y.position }
elements.each do |element|%>
<% if element.pratialname!="" then %>
<%=render :partial => element.pratialname , :locals => { :element
=> element } %>
<%else%>
<%=element.content%>
<%end%>
<%end%>