99m*_*les 6 inheritance ruby-on-rails
我发生了多态关联关系,当我通过它检索记录时,例如:
hour = my_model.find( keeper_id ).hours.where( "day = ?", day_index )
Run Code Online (Sandbox Code Playgroud)
然后尝试在其上调用update_attributes:
hour.update_attribute(:start_time, start_time)
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
NoMethodError (undefined method `update_attribute' for #<ActiveRecord::Relation:0x0000010458c708>):
activerecord (3.0.0) lib/active_record/relation.rb:373:in `method_missing'
Run Code Online (Sandbox Code Playgroud)
我认为这是因为我通过关系检索了记录.我怎么能绕过这个?