简体   繁体   中英

Which is the best way to structure the layouts in a Ruby on Rails project using bootstrap 3?

I usually don't work with the designers but now I have to do it all by myself due to their vacations. I created a main.css.scss on the app/assets/stylesheets directory. My idea was to put on the app/views/layouts/application.html.erb layout file:

<html>
<header></header>
<body>

<div id="container">  

<%= yield %>

</div>
</body>
<footer></footer>
</html>

And then on each controller just structure things on each view. Is that ok or I should just define other layout for each controller as well and yield the views of that controller??? that would create a structure like

a)master layout--yields-->controller layout--yields-->view

AGAINST

b)master layout--yields-->view (which could lead to code repetition)

1)Which is the correct way?. Cause it also worries me what happens if I define some grid system on the top layout and then define an incorrect grid system on the lower layouts/views that consume that upper layout...... 2)That bootstrap container should be there in the upper layout??

You can nest containers but I think its better to not put everything in a master container. In app/views/layouts/application.html.erb:

<html>
  <head>
    <title>Title</title>
  </head>    
  <body>    
    <%= render 'shared/header' %>
    <%= yield %>
    <%= render 'shared/footer' %>
  </body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM