Hi, after updating to rails1.0 (using the debian package) and following the instructions at http://manuals.rubyonrails.com/read/chapter/120 I always get in my rails application the following error: "undefined method `updated?'' for #<Device:0xb6c95564>" when I want to save (create or update) an interface or device-object (as explanation: devices are servers, which have many interfaces). Thank you in advance for your help to find my mistake! Kind Regards Peter My relevant code snippets are: ------------------- models/device.rb --------------------- class Device < ActiveRecord::Base belongs_to :devicetype belongs_to :devicemodel belongs_to :cabinet has_many :interfaces has_and_belongs_to_many :groups validates_presence_of :name, :he validates_uniqueness_of :name validates_numericality_of :he [...] end ------------------- models/device.rb --------------------- class Interface < ActiveRecord::Base belongs_to :device belongs_to :cable belongs_to :patchcable validates_presence_of :name, :device_id [...] end I want to add a comment to an existing interface, so here''s the update method: ------------------- controllers/interfaces_controller.rb --------------------- [...] def update @interface = Interface.find(params[:id]) unless @interface.device.is_writable(@logged_user) flash[:error] = ''Keine Berechtigung!'' redirect_to :action => ''show'', :id => @interface.id else if params[:interface][:upstream] != "1" params[:interface][:upstream] = '''' end if @interface.update_attributes(params[:interface]) flash[:notice] = ''Schnittstelle wurde aktualisiert.'' redirect_to :action => ''show'', :id => @interface else render :action => ''edit'' end end end [...] An interface object consists of name and comment and has relations to a server and a cable (and sometimes to an extra patchcable). The error message I get is: NoMethodError in Interfaces#update undefined method `updated?'' for #<Device:0xb6c95564> RAILS_ROOT: [...] (Full Trace, "#{RAILS_ROOT}" removed to get rid of some line breaks...) /vendor/rails/activerecord/lib/active_record/base.rb:1498:in `method_missing'' /vendor/rails/activerecord/lib/active_record/callbacks.rb:341:in `callback'' /vendor/rails/activerecord/lib/active_record/callbacks.rb:335:in `callback'' /vendor/rails/activerecord/lib/active_record/callbacks.rb:330:in `each'' /vendor/rails/activerecord/lib/active_record/callbacks.rb:330:in `callback'' /vendor/rails/activerecord/lib/active_record/callbacks.rb:248:in `create_or_update'' /vendor/rails/activerecord/lib/active_record/base.rb:1226:in `save_without_validation'' /vendor/rails/activerecord/lib/active_record/validations.rb:698:in `save_without_transactions'' /vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'' /vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `transaction'' /vendor/rails/activerecord/lib/active_record/transactions.rb:91:in `transaction'' /vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `transaction'' /vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'' /vendor/rails/activerecord/lib/active_record/base.rb:1267:in `update_attributes'' /app/controllers/interfaces_controller.rb:102:in `update'' /vendor/rails/actionpack/lib/action_controller/base.rb:853:in `perform_action_without_filters'' /vendor/rails/actionpack/lib/action_controller/filters.rb:332:in `perform_action_without_benchmark'' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `measure'' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' /vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in `perform_action'' /vendor/rails/actionpack/lib/action_controller/base.rb:369:in `process_without_session_management_support'' /vendor/rails/actionpack/lib/action_controller/session_management.rb:116:in `process'' /vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'' /var/www/ccm-psaenger.ncc.eurodata.de_8080/public/dispatch.cgi:12
Mark Reginald James
2006-Mar-17 03:33 UTC
[Rails] Re: please help: "undefined method ''updated?''"
Peter S?nger wrote:> after updating to rails1.0 (using the debian package) and following the > instructions at http://manuals.rubyonrails.com/read/chapter/120 > I always get in my rails application the following error: > "undefined method `updated?'' for #<Device:0xb6c95564>"You may like to contact the author of this message, who had the same problem: http://article.gmane.org/gmane.comp.lang.ruby.rails/37392 -- We develop, watch us RoR, in numbers too big to ignore.
Hi, thanks to Marshalls help, I figured out, that my problem was caused by a badly chosen name of a variable in the validates method of my interface model. Originally I called it @device, after renaming it the error was gone. Thanks Peter