Error submitting form

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

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

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.

http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001699

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

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

<% 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs