I have this model declared in schema.rb:
create_table "lot_reports", force: :cascade do |t|
t.integer "spaces_occupied"
t.integer "spaces_newly_occupied"
t.string "name"
t.time "time_stamp"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "lot_id"
end
When I try to access the spaces_occupied attribute on the model, I receive nil even when the database shows a value for that field.
LotReport Load (0.5ms) SELECT "lot_reports".* FROM "lot_reports" ORDER BY "lot_reports"."id" ASC LIMIT 1
#=> #<LotReport id: 1, spaces_occupied: 107, spaces_newly_occupied: 153, name: "Cummerata Field", time_stamp: "2000-01-01 23:13:25", created_at: "2015-03-07 23:19:42", updated_at: "2015-03-07 23:19:42", lot_id: 1>
LotReport.first.spaces_occupied
LotReport Load (0.5ms) SELECT "lot_reports".* FROM "lot_reports" ORDER BY "lot_reports"."id" ASC LIMIT 1
#=> nil
Not sure what's going on here. This is the only attribute that has this problem; the others return what I expect.
Edit: Here is the LotReport source code
class LotReport < ActiveRecord::Base
belongs_to :lot
def plot_array
[spaces_occupied, time_stamp]
end
end
LotReport's source code.