Topic: Why can't I read my models attribute?
I have a model TcDatum whose backend table has a string attribute (field) named 'leave'.
(I just added 'leave' with a rails migration)
I added 'attr_accessible :leave' to the active record definition for TcDatum.
However, when I reference the attribute from within a fields_for loop as in:
<% if pf.object.leave=='P' %>
I get the error "undefined method 'leave' for #<TcDatum:xxxxxxx>"
If I add it explicitly to the model with the code
then the fields_for code executes without error.
However, I want to read the field value from the model record, not create one with a def .. end.
What am I doing wrong that the model attribute 'leave' isn't being recognized in my code?
Thanks in advance for any help. --Fred
Last edited by fredrated (2012-04-19 13:36:23)