On May 26, 2011, at 5:30 PM, egervari wrote:

> This is unfortunate if that's how to solve it. What if 10 pages need
> to use this same sublayout... do I need to have an if condition that
> is 10 if/elsif's? That's not scalable :/

Well like I said you can set a variable -- local variable or instance variable 
-- and tell render to use that variable.

Or write a helper method and call <%= render :partial => what_to_render() %>

then put the 10 if/else's into a the what_to_render helper method. (or use case 
with a default case so you only put the special cases). It is ruby after all, 
almost anything can be made cleaner and more elegant. 


> 
> It would really be better to have a layout that is special to these 2
> pages that I can execute manually and wrap the content that is on the
> page. That way the content for that page is in the view it belongs to
> - not in the partial with an if/switch statement.


You can switch the layout in the controller, either on a 
controller-by-controller basis, or you can decide in a method which layout to 
use. 

render "hello.erb", :layout => "xyz"


Without really looking at your code I can't solve you problem, but I can throw 
a bunch of suggestions at you as to different ways it could be done  ;)

-Jason



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