Ruby On Rails Questions et reponses d'entretien
Question : What is the purpose of Layouts in Ruby on Rails?Reponse :Layouts are partial ruby/html files that are used to render the content pages. There are placed in the folder: app/views/layouts Items that you would typically put in this folder are things like headers/footers, navigation elements, etc. Here’s a sample layout file: /app/views/layout/application.html.erb <html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Learning System | <%= @page_title || 'Admin Area' %></title>
<meta name="author" content="Anil Punjabi">
<%= stylesheet_link_tag('public', 'admin', :media => 'all') %>
<%= javascript_include_tag('application') %>
</head>
<body>
<div id="header">
<h1>Learning System</h1>
</div>
<div id="main">
<% if !flash[:notice].blank? %>
<div class="notice">
<%= flash[:notice] %>
</div>
<% end %>
<div id="content">
<%= yield %>
</div>
</div>
<div id="footer">
<p id="copyright">© / Anil Punjabi</p>
</div>
</body>
</html>Say you are trying to access the page as shown below: Then the contents of the index.html.erb would be placed above in the section shown under <% yield %> above and sent back to the user. |
Enregistrer pour revision
Ajoutez cet element aux favoris, marquez-le comme difficile ou placez-le dans un ensemble de revision.
Connectez-vous pour enregistrer des favoris, des questions difficiles et des ensembles de revision.
Les plus utiles selon les utilisateurs :
- What is Ruby On Rails?
- Why Ruby on Rails?
- Explain how (almost) everything is an object in Ruby.
- What are Gems and which are some of your favorites?
- How would you declare and use a constructor in Ruby?