1

I'm writing a 4chan-like imageboard in Rails. It's my first Rails app after going through Michael Hartl's Rails tutorial, and I'm not sure how to organize my controllers.

I have a controller for posts, and a controller for pages. Is this how you would organize it? Do I even need a pages controller if I just want everything to happen on one page?

nnyby
  • 4,748
  • 10
  • 49
  • 105

1 Answers1

2

Having one page presented to the user doesn't necessarily effect how your structure that code ... you still need something to generate that page.

In your case, however, the display will be a list of posts. So you may not need a separate controller at all.

Assuming a rest-like structure, you would have:

Posts.index - list of posts
Posts.show - single post
Posts.create - create a post
etc
etc

So your index method becomes the "single page" and it can accept filtering parameters and display a list of posts accordingly.

Toby Hede
  • 36,755
  • 28
  • 133
  • 162