# Form error

**URL:** <https://www.ruby-forum.com/t/form-error/125897>\
**Category:** Rails\
**Created:** [January 13, 2008, 2:48pm UTC](https://www.ruby-forum.com/t/form-error/125897 "2008-01-13T14:48:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![extempore](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@extempore](https://www.ruby-forum.com/u/extempore)\
**Post date:** [January 13, 2008, 2:48pm UTC](https://www.ruby-forum.com/t/form-error/125897/1 "2008-01-13T14:48:48Z")

</div>

Dears I’m trying to get a form working in my application however I get  
the stack error for this in return.  
I allready found out that it’s situated in the def new declaration but  
have no clue how to solve this  
this is my controller

```auto
require "player"
class SpelersController < ApplicationController

  def index
    @speler = Speler.find(:all, :order => 'RAND()')
  end

  def all_sorted
  @heren=Speler.heren
  @dames=Speler.dames
  end

  def score_sn
  @senior=Speler.sr
  end

  def score_jr
    @junior=Speler.junior
  end

  def score_p
    @pupil =Speler.pupil
  end

 def score_top
   @man =Speler.topm
  @vrouw=Speler.topv
  end
def new
  @new = Speler.new
end
end
```

and this is my model

```auto
require
"C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record"
class Speler < ActiveRecord::Base
 @@ploegen={ 'P' => 'pupil', 'J' => 'junior', 'SR' => 'senior'}

# def initialize(naam, achternaam, geslacht, score, ploeg='SR')
# @naam = naam
# @achternaam = achternaam
# @geslacht = geslacht if geslacht == 'V' || geslacht == 'M'
# if @@ploegen.has_key?(ploeg)
# @ploeg = ploeg
# else
# @ploeg = 'SR'
# end
# @score = score
# end
  ActiveRecord::Base.establish_connection(
  :adapter => "mysql",
  :host => "localhost",
  :username => "root",
  :password => "",
  :database => "vspw"
  )
class CreateSpelers < ActiveRecord::Migration
    def self.up
      create_table :spelers do |t|
        t.column :naam,:string
        t.column :achternaam,:string
        t.column :score,:integer
        t.column :ploeg,:string
        t.column :geslacht,:string

      end
      # TODO: Hiervoor heb ik een speler.make (of iets dergelijks)
aangemaakt. Deze zorgt ervoor dat
      # oa de ploeg correct wordt opgevuld
      Speler.create :naam => "jan",:achternaam => "Janssens",:score
=>"5",:ploeg =>"SR",:geslacht =>"M"
      Speler.create :naam => "Leen",:achternaam => "Leniksen",:score
=>"7",:ploeg =>"",:geslacht =>"V"
      Speler.create :naam => "Piet",:achternaam => "Pietersen",:score
=>"3",:ploeg =>"",:geslacht =>"M"
      Speler.create :naam => "Els",:achternaam => "Elsenbocht",:score
=>"1",:ploeg =>"J",:geslacht =>"V"
      Speler.create :naam => "Karel",:achternaam => "Carlsen",:score
=>"8",:ploeg =>"",:geslacht =>"M"
      Speler.create :naam => "Mieke",:achternaam => "Mieters",:score
=>"9",:ploeg =>"P",:geslacht =>"V"
      Speler.create :naam => "John",:achternaam => "Johanssen",:score
=>"5",:ploeg =>"J",:geslacht =>"M"
      Speler.create :naam => "Veerle",:achternaam => "Veldsen",:score
=>"3",:ploeg =>"",:geslacht =>"V"
    end
    def self.down
      drop_table :Spelers
    end
    #CreateSpelers.down
    #CreateSpelers.up
  end
  def self.iedereen()
  Speler.find(:all )
end

  def to_s
sprintf(" #{naam} #{achternaam} - #{score} ")
end
def self.heren
  Speler.find(:all, :conditions =>{:geslacht =>"M"})
end
def self.dames
  Speler.find(:all, :conditions =>{:geslacht =>"V"})
end
def ploeg
  @@ploegen = :ploeg
end
def self.sr
 @senior = Speler.find_by_sql("select naam,achternaam, score,ploeg from
spelers WHERE ploeg = 'SR' OR ploeg =''")
end
 def self.pupil
  Speler.find(:all, :conditions =>{:ploeg =>"P"})
end
def self.junior
  Speler.find(:all, :conditions =>{:ploeg =>"J"})
end
def self.topm
  @man = Speler.find_by_sql("select naam,achternaam, score ,ploeg from
spelers where geslacht ='M' ORDER BY score DESC").first(3)
end
def self.topv
  @vrouw = Speler.find_by_sql("select naam,achternaam, score ,ploeg from
spelers where geslacht ='V' ORDER BY score DESC").first(3)
end
#select naam,ploeg from Spelers where ploeg ="SR" OR ploeg = "";
#puts "Alle senioren :"
def speler
  @speler= :speler
end

end
```

my form looks like this

# Een nieuw lid toevoegen
\<%= error\_messages\_for 'Speler' %\>
# Nieuwe speler

\<%= error\_messages\_for :speler %\>

\<% form\_for(@new) do |f| %\>

name:  
\<%= f.text\_field :naam %\>

achternaam:  
\<%= f.text\_field :achternaam %\>

Score:  
\<%= f.text\_field :score %\>

score:  
\<%= f.text\_field :ploeg %\>

 \<%= f.submit "Create" %\> \<% end %\>

[/code]  
I know the create part is not mentioned in the controller but since I  
first would like to solve the stack error I left this out.  
this is the stack error

SystemStackError in SpelersController#new

stack level too deep

RAILS\_ROOT: D:/Documenten/NetBeansProjects/Speler  
Application Trace | Framework Trace | Full Trace

C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/locking/optimistic.rb:55:in  
`attributes_from_column_definition_without_lock' C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/locking/optimistic.rb:55:in`attributes\_from\_column\_definition’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/base.rb:1922:in  
`initialize' app/controllers/spelers_controller.rb:31:in`new’  
app/controllers/spelers\_controller.rb:31:in `new’

C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/locking/optimistic.rb:55:in  
`attributes_from_column_definition_without_lock' C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/locking/optimistic.rb:55:in`attributes\_from\_column\_definition’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/base.rb:1922:in  
`initialize' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in`send’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/base.rb:1158:in  
`perform_action_without_filters' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in`call\_filters’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/filters.rb:689:in  
`perform_action_without_benchmark' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’  
C:/paul/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/rescue.rb:199:in  
`perform_action_without_caching' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in`perform\_action’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/connection\_adapters/abstract/query\_cache.rb:33:in  
`cache' C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in`cache’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/caching.rb:677:in  
`perform_action' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in`send’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/base.rb:524:in  
`process_without_filters' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in`process\_without\_session\_management\_support’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/session\_management.rb:123:in  
`process' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in`process’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/dispatcher.rb:171:in  
`handle_request' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in`dispatch’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/dispatcher.rb:126:in  
`dispatch_cgi' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in`dispatch’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick\_server.rb:112:in  
`handle_dispatch' C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in`service’  
C:/paul/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' C:/paul/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in`run’  
C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:162:in`start’  
C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:95:in`start’  
C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:92:in`start’  
C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:82:in`start’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick\_server.rb:62:in  
`dispatch' C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66 C:/paul/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
C:/paul/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' C:/paul/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in`require’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active\_support/dependencies.rb:342:in  
`new_constants_in' C:/paul/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in`require’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39  
C:/paul/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' C:/paul/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3

C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/locking/optimistic.rb:55:in  
`attributes_from_column_definition_without_lock' C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/locking/optimistic.rb:55:in`attributes\_from\_column\_definition’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/base.rb:1922:in  
`initialize' app/controllers/spelers_controller.rb:31:in`new’  
app/controllers/spelers\_controller.rb:31:in `new' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in`send’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/base.rb:1158:in  
`perform_action_without_filters' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in`call\_filters’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/filters.rb:689:in  
`perform_action_without_benchmark' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’  
C:/paul/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in`perform\_action\_without\_rescue’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/rescue.rb:199:in  
`perform_action_without_caching' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in`perform\_action’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/connection\_adapters/abstract/query\_cache.rb:33:in  
`cache' C:/paul/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in`cache’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/caching.rb:677:in  
`perform_action' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in`send’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/base.rb:524:in  
`process_without_filters' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in`process\_without\_session\_management\_support’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/session\_management.rb:123:in  
`process' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in`process’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/dispatcher.rb:171:in  
`handle_request' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in`dispatch’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/dispatcher.rb:126:in  
`dispatch_cgi' C:/paul/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in`dispatch’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick\_server.rb:112:in  
`handle_dispatch' C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in`service’  
C:/paul/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' C:/paul/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in`run’  
C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:162:in`start’  
C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:95:in`start’  
C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:92:in`start’  
C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' C:/paul/ruby/lib/ruby/1.8/webrick/server.rb:82:in`start’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick\_server.rb:62:in  
`dispatch' C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66 C:/paul/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
C:/paul/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' C:/paul/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in`require’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active\_support/dependencies.rb:342:in  
`new_constants_in' C:/paul/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in`require’  
C:/paul/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39  
C:/paul/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' C:/paul/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3

Request

Parameters:

None

Show session dump

* * *

flash: !map:ActionController::Flash::FlashHash {}

Response

Headers:

{“cookie”=\>[],  
“Cache-Control”=\>“no-cache”}

thanks for the help

---

<div class="post-metadata">

**Author:** ![extempore](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@extempore](https://www.ruby-forum.com/u/extempore)\
**Post date:** [January 13, 2008, 5:08pm UTC](https://www.ruby-forum.com/t/form-error/125897/2 "2008-01-13T17:08:55Z")

</div>

I also found out in the mean time that the problem is situated in the  
def new part in the controller but even with a new project when trying  
to use the same code I get a stack overflow  
can anyone help me out please  
your help is much appreciated

---

<div class="post-metadata">

**Author:** ![extempore](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6bbea6/32.png) [@extempore](https://www.ruby-forum.com/u/extempore)\
**Post date:** [January 13, 2008, 8:06pm UTC](https://www.ruby-forum.com/t/form-error/125897/3 "2008-01-13T20:06:22Z")

</div>

is there anyone out here who could help me with this  
since I’m still learning I and want to avoid this type of error in the  
future I would like to know what I did wrong?  
thanks for your help

Paul P. wrote:

> I also found out in the mean time that the problem is situated in the  
> def new part in the controller but even with a new project when trying  
> to use the same code I get a stack overflow  
> can anyone help me out please  
> your help is much appreciated
