Front page controller?

I'm new to Ruby on Rails and I'm sure this question is pretty stupid, but I can't seem to deduce the answer from the examples I've seen, maybe I haven't seen many good ones.

The website I'm working on will display "boxes" (ie widgets) in one sidebar that will contain dynamic content, as well as links in the other sidebar to sections of the website that will be handled by different controllers. The layout / style of the website will remain the same across all controllers. For example, if I click on one link, the content in the center changes, while the rest of the site's design and layout remains the same.

My question is, should I create something like a controller home

that will handle the start page and site layout, then somehow yield to a specific controller layout if called, then specify that the controller is the root controller in routes.rb

? I'm just wondering how am I going to talk about the layout should remain relatively the same so that I don't have to redundantly and inject the same layout code for each controller. This is what someone on IRC recommended to create a controller home

, but I wanted to know if this was the usual way of doing things. The answer may be really simple for anyone I care, but since I'm new to rails, I forget.

I really don't know how to properly state my question, since I'm relatively new to rails. If something doesn't make sense, please let me know and I'll try to clarify.

Thank.

+2


source to share


2 answers


Yes, you can use page_controller for that and set that as root url in route.rb.



Remember, you don't need to use a separate layout file for each controller if you don't want to. If you create a file at layouts / application.html.erb, it will be used throughout the application. You can override it by creating other layouts named according to the controller to be automatically raised, or set layout: other_name in your controller to change it.

+3


source


If you create a file application.html.erb

in the layouts folder, it will be used by default by any controller that does not have a layout file in the layouts folder. Alternatively, you can manually specify the layout to use in the controller by adding:

layout "your_layout_name"

      



in your controller.

+1


source







All Articles