**
Le 27 août 2010 06:56:13 UTC+2, Chris <[email protected]> a écrit :

> I've learned how to dynamically change which layout is used at
> runtime, but I now have a question of whether it is possible to create
> new layouts (or modify existing ones) at runtime and have the app
> automatically recognize those changes?  If so could you point me to an
> example or explain how it would be done.
>

Have you ever tried using partials? Partials can work you wonders. You need
to have several partials (with varied layouts as you wish) and have one *main
view* that calls them and switch them depending on a given condition. I have
a similar situation in some apps I work on. I give users different
"dashborad" layouts depending on their roles.

Let me give you a practical example:

<div id = "patient_dashboard">
<div id="details">
    <%= render :partial => "details" %>
    <% if @super_user || @doctor || @nurse%>
      <%= render :partial => "simple_graph",
        :locals=>{:fields=>@patient}  rescue nil%>
    <%end%>

    <%= render :partial => "patient_visit_summary" %>
  </div>

  <div id="menu">
    <%if @doctor%>
     <%= render :partial => "doctors_menu" %>
    <%elsif @clinician%>
      <%= render :partial => "clinicians_menu" %>
    <%<%elsif @nurse%>
      <%= render :partial => "nurses_menu" %>
    <%<%elsif @registration_clerk%>
      <%= render :partial => "clerks_menu" %>
    <%elsif @super_user%>
      <%= render :partial => "super_users_menu" %>
    <%end %>
  </div>
</div>

Please let us know if it works for you.

---
Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/) |
Malawi

Cell:  +265 999 465 137 | +265 881 234 717

*"Many people doubt open source software and probably don’t realize that
there is an alternative… which is just as good.." -- Kevin Scannell*

-- 
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.

Reply via email to