twinkle mehta
twinkle mehta

Reputation: 9

About some tags in rails program

i have got this program in ruby editor.My output comes out to be

<html>
<head><title> Ruby on Rails tutorial Sample App | <%= @title %></title>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>

what is the error here and what is yield and csrf_meta_tag?

Upvotes: 0

Views: 64

Answers (3)

Salil
Salil

Reputation: 47472

Ref yield & content_for

Within the context of a layout, yield identifies a section where content from the view should be inserted. The simplest way to use this is to have a single yield, into which the entire contents of the view currently being rendered is inserted:

<html>
  <head>
  </head>
  <body>
  <%= yield %>
  </body>
</html>

You can also create a layout with multiple yielding regions:

<html>
  <head>
  <%= yield :head %>
  </head>
  <body>
  <%= yield %>
  </body>
</html>

The main body of the view will always render into the unnamed yield. To render content into a named yield, you use the content_for method.

Upvotes: 0

chech
chech

Reputation: 1105

You don't seem to be using a server to render the views, it seems like you are rather loading the html directly on your browser.

Maybe the following link will help you get started:

http://guides.rubyonrails.org/getting_started.html

Upvotes: 2

ernd enson
ernd enson

Reputation: 1764

you need to rename your file from:
application.html to be application.html.erb so that it is going to interpret your embedded ruby commands.

Upvotes: 0

Related Questions