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

Ruby

dylan kane
dylan kane
2,772 Points

where to put html files in a ruby on rails project

so i coded a website in html and that part is finished, did it with bootstrap. now i would like to start incorporating ruby into it with rails, how and where do I put the html files in the project

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

You mentioned, rails, which has a specific folder structure. Rails does not use a straight html file. Instead, your view files like your HTML template would go into the views folder of your rails app, and the file names would have to have a .erb appended to them, so index.html would become index.html.erb. That will allow you to dynamically bring content into the view.

dylan kane
dylan kane
2,772 Points

so i would put everything in the public folder and then append .erb onto everything and I would be good to go?

Kevin Korte
Kevin Korte
28,149 Points

Are you specifically asking about Ruby, or Ruby on Rails? Rails is going to have specific way to do it. Ruby you'd be a bit more free where to put your views, but you also have to hook up the routes. How should I answer this? Rails specific or not?

dylan kane
dylan kane
2,772 Points

rails specific please

Kevin Korte
Kevin Korte
28,149 Points

It's almost easier to show you, and to say I would highly recommend learning about MVC frameworks, and taking some of the rails courses here.

With that, I have a very messy repo you can look at. I'm rebuilding this site in a new repo to eliminate a lot of the "development" clutter know that I know what I want. You can see the entire app, but what you're looking for is in the APP >> VIEWS folder. There are a bunch of folders that contain my html.erb views, which are more or less HTML. How the views are structured in the folders relates back to the routes.rb file that can be found CONFIG folder. Those routes pass along to controllers which talk to the models, which get data from the database, and send it all back to the views.

Here is the repo: https://github.com/kevinkorte/mcs_rails

Again, its gross and messy, but it does work, and it does serve it's purpose here.