Reputation: 410
I'm playing on rails console and did the following steps:
agendamento = Agendamento.last
And got a record that looks like this
#<Agendamento id: 4, sala_id: 2, name: "Delta C", start_at: "2013-10-11 02:00:00", end_at: "2013-10-10 04:00:00", bookingDate: "2013-10-10",
bookingTime: "2000-01-01 23:00:00", bookingDuration: 2, approved: true, usuario_id: nil, created_at: "2013-10-05 02:24:00", updated_at: "2013-
10-05 02:24:00">
when I do agendamento.name
I receive:
Delta C
and it works in all values, but not on sala_id
, agendamento.sala_id
returns
nil
This attribute is acessible in the model, why it is returning nil ?
Environment: Ruby 2 and Rails 4
Upvotes: 0
Views: 50
Reputation: 46183
If sala_id
is a foreign key reference, have you tried invoking sala
instead? That should give you the related object.
Upvotes: 1