[LRUG] Moving logic from view to controller/model

Tom Stuart tom at experthuman.com
Fri Jul 25 14:45:11 PDT 2008


On 25 Jul 2008, at 18:14, Kevin Fullerton wrote:
> clearing the habtm association if none are selected, apart from  
> where the user is admin and the Role is System Administrator – that  
> must always be selected
> So – should this go in the model in a before_save callback or in the  
> controller – my gut says model

Yes, it belongs in the model; set up a callback to add the  
administrator role (to only the admin user) if it's been removed. In  
fact, assuming that the habtm :roles is :uniq (it should be), then you  
can just add it regardless.

Cheers,
-Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20080725/c693732d/attachment-0003.html>


More information about the Chat mailing list