Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

chris salvi
chris salvi
7,584 Points

For making dynamic websites with Rails functionality, what is the best way to design?

One thing I still have some trouble understanding in the dense forest known as MVC land is where the actual html code goes. Yes Im aware that Views stores what the viewer is suppose to see, but there are so many sub files for even that on a basic app.

Is it a bad idea to design a webpage first in basic html5/css3/ a tad of js and then scaffold on the more advanced features later? How would you go about doing so?

Kevin Murphy
Kevin Murphy
24,380 Points

Great question, I'd like to learn more about this process as well.

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Chris;

In a nutshell MVC can be thought of like this:

  1. Model

The classes which are used to store and manipulate state, typically in a database of some kind.

  1. View

The user interface bits (in this case, HTML) necessary to render the model to the user.

  1. Controller

The brains of the application. The controller decides what the user's input was, how the model needs to change as a result of that input, and which resulting view should be used.

So, in answer to your question, your HTML code goes into the View files. There is, of course, much more to most frameworks than that, but from a high level point of view, that's the process.

Happy coding,

Ken

chris salvi
chris salvi
7,584 Points

Ken Alger

I get the basic premise of MVC, but for example, on the odot application there are folders and subfolders for many different things

-notifier -password_reset -todo_items -todo_lists -user session _user

Those last two especially confuse me in the context of html. What are we viewing in a user session that isnt already encapsulated by the other areas?

Ken Alger
Ken Alger
Treehouse Teacher

Chris;

Great questions. It has been a while since I have gone through the ODOT Application in Ruby On Rails so I may be a little hazy on the specifics actions within each folder. It looks like the subfolders you listed are all under the app>views folder, correct? These are all, generally, dealing with the View construct of the MVC and will be called upon by the Controller based upon the coding for the routes. The subfolders will also show up in the site URL, so naming them something meaningful like todo_items will help for SEO.

For the ODOT application specifically I believe the /user subfolder deals with the editing and adding new users to the site while the user_session concerns itself with users logging into the site and establishing a session.

It take a bit of work, at least it did for me, to get a good grasp on what is doing what in an MVC like Rails. I wound up creating several basic sites that initially didn't have much other than static pages with no database connections and little, if any, CSS/SASS modifications. Once you build a few views, under some subfolders, and get the "static" site functioning with the correct routing done and that makes sense, then increase the functionality of the site. There is a lot to comprehend, yes. But build a site or two on your own and if/when you get stuck ask questions here in the forum or search online for other resources.

Hope my rambling helped a bit.

Ken