开发者

Rails design of an online newspaper -- controllers

I have started a Ruby on Rails 3 project to make an online version of newspaper. The front page has the news headlines, sports headlines and life headlines. It has all the headlines for the different sections of the site.

All the stories are stored in one table and photos in another table. It is a very simple set up. I am trying be DRY but I can't seem to avoid it. On the index action page I have to look up sports stories and on the sports action page I have to look up sports.

My question is shoul开发者_C百科d I make a different controller for every category? Or have a main controller with categories as actions? ( which is what I am doing now? )


I would have a single Story controller that takes a querystring to determine the category. In other words, if you go to

/stories/

you get the front page, which lists all (or a portion of all) stories. If you want sports you go to

/stories/?category=sports

and the Story controller filters the list of stories (and presumably alters the view headings, etc.) based on the querystring.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜