#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 %>
<%= question.text %> | <%= text_area_tag "answer_#{question.id}",@answers[question.id], :cols=>"100", :rows=>"3" %> |
---|