Controller structures

Hello,

I am building a small test application for learning RoR. I understand
most of what is going on and all my relations is set up correctly.
(tested with console) I can’t figure out when to spilt out models into
separate controllers. Is it overkill to create a controller for each
model? Let me give an example.

Users -> Pos -> Comments

The show post page will display the Post and it’s comments. At the
moment I got a Post controller with CRUD (R both post and comments)
and a Comments controller with CUD. Would it make sense to merge these
two controllers into one controller?

Best regards.
Asbjørn Morell.

It’s a design decision, but I think yes if only so that you easily get
seperate views/view helpers as I’m sure a Post and a Comment will look
different.

If you have lots of similar bits it each then you can put them in a
module/mixin in the lib directory.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs