From: Shef Date: 2010-09-10T02:52:07+09:00 Subject: File upload help I'm fairly new to rails and I'm trying to understand an error it's giving me. I'm trying to upload some text files to a rails app of mine and I keep getting a SystemStackError error(stack too deep), but what I'm trying to do seems simple enough. So here's the code from the model: def title=(doc_field) self.title = doc_field.to_s end def article=(doc_field) self.body = doc_field.to_s end def originals=(doc_field) self.originals = doc_field.to_s end def corrections=(doc_field) self.corrections = doc_field.to_s end and the error rails issues: /mnt/transfer/apps/rails/blog_poster/app/models/config_docs.rb:16:in `corrections=' /mnt/transfer/apps/rails/blog_poster/app/models/config_docs.rb:16:in `corrections=' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ base.rb:2906:in `send' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ base.rb:2906:in `assign_attributes' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ base.rb:2902:in `each' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ base.rb:2902:in `assign_attributes' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ base.rb:2775:in `attributes=' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ base.rb:2473:in `initialize' /mnt/transfer/apps/rails/blog_poster/app/controllers/ article_controller.rb:13:in `new' /mnt/transfer/apps/rails/blog_poster/app/controllers/ article_controller.rb:13:in `upload' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/base.rb:1331:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/base.rb:1331:in `perform_action_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/filters.rb:617:in `call_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/filters.rb:610:in `perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/ active_support/core_ext/benchmark.rb:17:in `ms' /usr/local/lib/ruby/1.8/benchmark.rb:308:in `realtime' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/ active_support/core_ext/benchmark.rb:17:in `ms' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/rescue.rb:160:in `perform_action_without_flash' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/flash.rb:151:in `perform_action' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/base.rb:532:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/base.rb:532:in `process_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/filters.rb:606:in `process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/base.rb:391:in `process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/base.rb:386:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/routing/route_set.rb:438:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dispatcher.rb:87:in `dispatch' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dispatcher.rb:121:in `_call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dispatcher.rb:130:in `build_middleware_stack' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/string_coercion.rb:25:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/string_coercion.rb:25:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/ methodoverride.rb:24:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/params_parser.rb:15:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/session/abstract_store.rb:128:in `call' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ query_cache.rb:29:in `call' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ connection_adapters/abstract/query_cache.rb:34:in `cache' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ query_cache.rb:9:in `cache' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ query_cache.rb:28:in `call' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/ connection_adapters/abstract/connection_pool.rb:361:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/failsafe.rb:26:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dispatcher.rb:114:in `call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/reloader.rb:34:in `run' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dispatcher.rb:108:in `call' /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/static.rb: 31:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:47:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in `each' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in `call' /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/ log_tailer.rb:17:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/ content_length.rb:13:in `call' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/ webrick.rb:48:in `service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/ webrick.rb:14:in `run' /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb: 111 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' script/server:3 From searching around this seems to have something to do with recursion, but I'm not sure how. I assumed the objects in the model would be file-like, so I tried to use the read method on them, but instead they returned a string or an array object. After that I tried to_s and got the aforementioned error. Any help on this would be massively appreciated, :D