rails/rails — Issue #5265: ActiveModel::MissingAttributeError
Author: intechltd
Created: 2012-03-04 02:55:12+00:00
State: open

Does anybody know, why i am getting ActiveModel::MissingAttributeError exception if i just trying to update the following model:

class CreateOffers < ActiveRecord::Migration
def change
create_table :offers do |t|
t.string :number
t.integer :status
end
end
end

class Offer < ActiveRecord::Base
STATUSES = 1..4
validates :status, :inclusion => { :in => STATUSES }, :allow_blank => true, :allow_nil => true
end

Offer.create(:number => '1234', :status => 1) # Successfully

offer = Offer.select('number').find(id)
offer.number = 'new number'
offer.save # Here comes that noisy ActiveModel::MissingAttributeError

I've been spending 4 hours investigating with no success. Any help appreciated.