I need some overview thinking help.
I have Pictures model/controller but generally, I want to show pictures via a partial displayed in other controller views and I want to do things like choose the picture based upon various concepts of relevance. I also want to update a 'view_count' column in the Pictures model each time it is displayed.
So if in a partial in /users controller, I would love to be able to call some Picture method (either model or controller but probably controller is the more logical choice) but I can't figure a way to do this...
<%= PictureController.some_method %> clearly gives me an error
if I try to put that code into a model...
<%= Picture.some_method %> I am still up a creek without a paddle
this works but clearly doesn't belong in a view...
<% @pic_1 = Picture.find(:first, :conditions => ["active = true"], :order => 'view_count'); @pic_1.view_count += 1; @pic_1.save! %>
And of course my problem is that I want to use this 'partial' in a bunch of different controllers & actions which is why I don't want to include it in each controller/method.
What is the best way to handle something like this?
Craig