# Error submitting form

**URL:** <https://www.ruby-forum.com/t/error-submitting-form/145725>\
**Category:** Rails\
**Created:** [August 13, 2008, 11:24am UTC](https://www.ruby-forum.com/t/error-submitting-form/145725 "2008-08-13T11:24:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![verifier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@verifier](https://www.ruby-forum.com/u/verifier)\
**Post date:** [August 13, 2008, 11:24am UTC](https://www.ruby-forum.com/t/error-submitting-form/145725/1 "2008-08-13T11:24:37Z")

</div>

Hi

I just started learning ruby on rails.  
Now i’ve made a simple form with a textfield and a submit button.

* * *
 -------------------------------------------------------

When i submit my form i have an error called  
-\> ActionController::InvalidAuthenticityToken in MainController#mainup

I’ve this error in firefox when i try the same form in IE i have no  
errors and it works fine.

I’ve found a solution that works fine and i need to add this line to my  
form

This solution is fine for one time but i don’t like every time i have a  
form to add this line!  
So my question is, isn’t there a final solution for this problem so i  
don’t need to add this line every time i’m using a form?

Regards

---

<div class="post-metadata">

**Author:** ![verifier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@verifier](https://www.ruby-forum.com/u/verifier)\
**Post date:** [August 13, 2008, 11:33am UTC](https://www.ruby-forum.com/t/error-submitting-form/145725/2 "2008-08-13T11:33:40Z")

</div>

On 13 Aug 2008, at 10:24, Jonas Goderis wrote:

> This solution is fine for one time but i don’t like every time i  
> have a  
> form to add this line!  
> So my question is, isn’t there a final solution for this problem so i  
> don’t need to add this line every time i’m using a form?

Use the rails form helpers (form\_for, form\_tag etc…)

Fred

---

<div class="post-metadata">

**Author:** ![verifier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@verifier](https://www.ruby-forum.com/u/verifier)\
**Post date:** [August 13, 2008, 11:37am UTC](https://www.ruby-forum.com/t/error-submitting-form/145725/3 "2008-08-13T11:37:48Z")

</div>

yes, use the form\_helpers, instead of pure html forms

\<% form\_tag :controller =\> “some\_controller”, :action =\> “some\_action”  
%\>  
\<%= text\_field “txtName” %\>  
\<%= submit “submit” %\>  
\<% end %\>

and so on. there are many methods in Rails to create  
forms and other html.  
If you start using Models, you’ll most likely use form\_for  
instead of the more simple form\_tag.

You should start reading some tutorials on Rails and the API docs  
or you will miss it’s main points and don’t get the benefits.

> **[ActionView::Helpers::FormTagHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001699)**
>
> Provides a number of methods for creating form tags that don't rely on an Active Record object assigned to the template like FormHelper does. Instead, you provide the names and values manually.

---

<div class="post-metadata">

**Author:** ![verifier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@verifier](https://www.ruby-forum.com/u/verifier)\
**Post date:** [August 13, 2008, 1:12pm UTC](https://www.ruby-forum.com/t/error-submitting-form/145725/4 "2008-08-13T13:12:12Z")

</div>

Ok thx, i’ll check the form helpers and do some tutorials 🙂  
Thx for the help

---

<div class="post-metadata">

**Author:** ![verifier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@verifier](https://www.ruby-forum.com/u/verifier)\
**Post date:** [August 13, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/error-submitting-form/145725/5 "2008-08-13T15:59:21Z")

</div>

On 13 Aug 2008, at 14:41, Jonas Goderis wrote:

> Ruby on rails use \<%= to write something on the page …  
> But isn’t there no other function who does that?

form\_tag and some others are a bit special and use. Not sure what you  
mean by “But isn’t there no other function who does that?”

The above should be \<% form\_tag :controller =\>  
“some\_controller”, :action =\> “some\_action” do %\>  
Fred

---

<div class="post-metadata">

**Author:** ![verifier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@verifier](https://www.ruby-forum.com/u/verifier)\
**Post date:** [August 13, 2008, 3:41pm UTC](https://www.ruby-forum.com/t/error-submitting-form/145725/6 "2008-08-13T15:41:43Z")

</div>

> \<% form\_tag :controller =\> “some\_controller”, :action =\> “some\_action”  
> %\>  
> \<%= text\_field “txtName” %\>  
> \<%= submit “submit” %\>  
> \<% end %\>

Ruby on rails use \<%= to write something on the page …  
But isn’t there no other function who does that?

thx
