[Rails] Re: Right way to pass conditionals to partials

brez! !! jbresnik at gmail.com
Sat Apr 15 20:04:44 GMT 2006


> There has to be a better way to do this.

What abt a Helper() ?  If nothing else you could consolidate the 
convoluted IF statements.. Looks like youre tyring to do a role based 
exposure of controls , e.g. an admin can see this button, etc.  If so it 
might be worth considering some kind of container that would have the 
html controls [do don't this in the model tho - bad violation of MVC] 
for a given roll - then the view [your .rhtml] can simply render whats 
in the container [probably just a plain old ruby object] - the 
controller would of course populate the container based on the role of 
the current user. This way your view simply renders whats there [which 
could mean nothing, if applicable].. this would alleviate the need for 
any role-type processing in your partials, i.e. avoid the problem all 
together.


-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list