0

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?

  • 1
    I don't know - what _is_ the error here (what's going wrong?) – Chowlett Jul 09 '13 at 10:34
  • `yield` will render the view for the current controller action and `csrf_meta_tag` will output the csrf meta tag. What error are you seeing? – sosborn Jul 09 '13 at 10:38
  • As for what `csrf_meta_tag` is doing - see [this question](http://stackoverflow.com/questions/941594/understand-rails-authenticity-token) on what it's preventing, and [this one](http://stackoverflow.com/questions/9996665/rails-how-does-csrf-meta-tag-work) on how. – Chowlett Jul 09 '13 at 10:39
  • i'm getting answer as : on browser window – twinkle mehta Jul 09 '13 at 11:04

3 Answers3

2

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

chech
  • 1,065
  • 14
  • 21
0

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.

ernd enson
  • 1,694
  • 1
  • 14
  • 28
0

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.

Salil
  • 43,381
  • 19
  • 113
  • 148