Authenticity Token!

#Answer_controller
def index
Hi!
I have next problem… Please help me understand how token works?? I
need create each form for each user… i mean, one user can see my form
only once! (unique session)…

@answers=Hash.new
if request.post?
questions = Question.find(:all,:conditions=>“enabled=1”)
questions.each do |question|
if params[“answer_”+question.id.to_s]
@answers[question.id]=params[“answer_”+question.id.to_s]
if !
Answer.create(:question_id=>question.id,:text=>params[“answer_”+question.id.to_s])
flash[:error]=“Can`t create answer!”
end
end
end
if !flash[:error]
redirect_to :action=>“pass”
return false
end
end

 @questions = Question.find(:all,:conditions=>"enabled=1")

end

#view answer.html.erb

Survey SIMPLE

<% form_tag do %>

<% @questions.each do |question| %> <% end %>
<%= question.text %> <%= text_area_tag "answer_#{question.id}",@answers[question.id], :cols=>"100", :rows=>"3" %>
<%= submit_tag 'Pass survey' %> <% end %>

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