My application is so far mostly built from scaffold. When I edit an existing record (I''ve turned off validation) the update method is called. I get this error: NoMethodError in <module>/<controller>#update You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.+ I get the same error when I call update_attributes from the console Any ideas? The stack trace is below. Thanks, Peter /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/locking.rb:37:in `update_without_callbacks'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:274:in `update_without_timestamps'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/timestamp.rb:39:in `update'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1718:in `create_or_update_without_callbacks'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:249:in `create_or_update'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1392:in `save_without_validation'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/validations.rb:724:in `save_without_transactions'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/transactions.rb:126:in `save'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/transactions.rb:91:in `transaction'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/transactions.rb:118:in `transaction'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/transactions.rb:126:in `save'' /web/server/pkgs/ruby-1.8.4/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1439:in `update_attributes'' #{RAILS_ROOT}/app/controllers/admin/library_controller.rb:39:in `update'' -- Posted via http://www.ruby-forum.com/.
Hi Peter, Peter Ensch wrote:> My application is so far mostly built from scaffold.That ''mostly'' thing will getcha from time to time ;-) It will help to see your code. Could you post the code from the update method? Also, the view / form that''s calling the method? Best regards, Bill
Bill Walton wrote:> > It will help to see your code. Could you post the code from the update > method? Also, the view / form that''s calling the method? >Sure. Here''s the update method (from app/controllers/admin/library_controller.rb): ############################## class Admin::LibraryController < ApplicationController ... def update @library = Library.find(params[:id]) if @library.update_attributes(params[:library]) flash[:notice] = ''Library was successfully updated.'' redirect_to :action => ''show'', :id => @library else render :action => ''edit'' end end ############################## Here''s the rendered form from ( app/views/admin/library/edit.rhtml app/views/admin/library/_form.rhtml app/views/layouts/admin/library.rhtml): ############################## <html> <head> <title>Admin::Library: edit</title> <link href="/stylesheets/scaffold.css?1147799338" media="screen" rel="Stylesheet" type="text/css" /> </head> <body> <p style="color: green"></p> <h1>Editing library</h1> <form action="/admin/library/update/121" method="post"> <!--[form:library]--> <p><label for="library_name">Name</label><br/> <input id="library_name" name="library[name]" size="30" type="text" value="SR60LX" /></p> <p><label for="library_macro_case">Macro case</label><br/> <input id="library_macro_case" name="library[macro_case]" size="30" type="text" value="lower" /></p> <p><label for="library_naming_convention">Naming convention</label><br/> <input id="library_naming_convention" name="library[naming_convention]" size="30" type="text" value="standard" /></p> ... much more here... <!--[eoform:library]--> <input name="commit" type="submit" value="Edit" /> </form> <a href="/admin/library/show/121">Show</a> | <a href="/admin/library/list">Back</a> </body> </html> ############################## -- Posted via http://www.ruby-forum.com/.
Possibly Parallel Threads
- [LLVMdev] [PATCH] utils/unittest: Consistency of gtest and gtest_main libs.
- 1.9.2 why does relative_require need an additional backtrack in path
- Understanding the version handling in LLVM/Clang/LLD
- 10.0.1-rc1 release has been tagged
- 10.0.1-rc1 release has been tagged