>On 26 July 2011 03:59, Leigh Daniels <leighdaniel...@gmail.com> wrote: >> Hi All, >> >> I have a very puzzling problem with a Rails 3.1.0.rc4/.rc5 app and I >could be missing something very obvious. >> >> I have a table (workunits) with a column (worked_seconds) that I can't >read or write. I've run migrations to remove and re-add it and I still >have the issue. >> >> If I manually add a value to the column in the table using Sequel Pro, >AR returns a record that includes the correct value of the column (see >below) but referencing the column via @workunit.worked_seconds returns >nil (see below). >> >> [...] >> >> class Workunit < ActiveRecord::Base >> belongs_to :user >> belongs_to :task >> >> attr_accessor :worked_seconds > >That is the problem, attr_accessor creates access methods that >override those that access the database columns. Remove this line (or >perhaps you meant attr_accessible?). > >Colin >
Thank you, Colin!! I was pretty sure it was a case of Rails doing what I told it to do and not what I meant for it to do. I did mean "attr_accessible". **Leigh -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.