views:

249

answers:

2

i am working on cms in which users submits articles and visitors can vote on those articles, so i am confused. should i make a vote behavior (since it deals with data) or i will me it on a component (because it is an action in my controller) ?

help is very appreciated.

+2  A: 

Neither. Behaviors are for applying the same functionality ("behavior") to multiple models. Only your Article model is "voteable". Likewise, Components are for re-using the same functionality in multiple Controllers, but again, only the Article controller needs a vote action.

Perhaps in your Article views (index listing and single view), you may want to create a vote Element that gets rendered next to each article title in the index view, and next to the title in the single Article view as well. Since this "vote widget" is needed in at least 2 different views, writing it as an Element makes perfect sense.

I hope this clarifies things a bit for you.

NOSLOW

+1  A: 

NOSLOW pretty much has it nailed, but he didn't mention the model part. If it were me, I would make a Votes model. I usually use the models to deal with data (fat models). Have the controllers handle the request, shepard the data, and pass it off to the fat model.

As NOSLOW said, I would make the voting section an element to include in your views.

Travis Leleu