views:

131

answers:

2

I'm trying to learn ruby on rails. I've been going through a tutorial, but I've gotten stuck.

It has me using start_form_tag and end_form_tag around an input form. However, when I access the page, I get undefined method 'start_form_tag' for #<ActionView::Base:0x2556020>

In the tutorial, they explain that these two lines are translated into <form action="/book/create" method="post"> and </form>. As such, I tried putting those instead. The form out come up, but when I submitted the form, I get this error: ActionController::InvalidAuthenticityToken in BookController#create

So,

  1. What do I have to do to get start_form_tag to translate correctly?
  2. Is this causing the InvalidAuthenticityToken error?
+3  A: 

The tutorial you're reading is outdated. Forms are now built using form_for blocks.

You can find a more up-to-date (and official) guide here. You can probably use it to complete the tutorial you're doing now.

Veeti
+7  A: 

I had the same problem when I started learning Rails. You have tutorial for old Rails version. start_form_tag is no longer used. I think the best place to learn Rails is Rails Guides

So, your question now. You can add form like this:

<% form_for @book do |f| %>
  <%= f.label :title %>
  <%= f.text_filed :title %>
  ...
  <%= f.submit 'Create' %>
<% end %>
klew