I am working with Ruby on Rails, fairly new with Rails. Whenever I query objects, the created_at and updated_at fields are nil on the ruby object.
When I use sqlitebrowser to examine the backend, I can see that the field has a value. I am using rails console to figure this out.
jwilliam@ubuntu:~/rails/devminder$ rails console
Loading development environment (Rails 4.1.8)
2.2.2 :001 > Instance.all
Instance Load (1.1ms) SELECT "instances".* FROM "instances"
=> #<ActiveRecord::Relation [#<Instance id: 1, title: "test" ec2id: "", created_at: nil, updated_at: nil, can_ice: 0>]>
2.2.2 :002 > SQLite3::Development.new('db/development.sqlite3').execute("select instances.* from instances")
=> [[1,"test", "", "2015-06-29 15:35:10.012611", "2015-06-29 15:35:10.012611", 0]]
When I execute Instance.all I see that I am getting nil for created_at and updated_at, however executing the query directly to SQLite3 shows that there are values, and it is not mapping them to ActiveRecord attributes properly.
I have a Rails project, using a SQLite3 backend. I am sure I have done something to jam this app up, but I am trying to figure it out.
file app/models/instance.rb
class Instance < ActiveRecord::Base
end
file app/models/schedule.rb
class Schedule < ActiveRecord::Base
#table schedules has an instance_id field...
belongs_to :instance
end
Aucun commentaire:
Enregistrer un commentaire