Michael Pavling wrote: > On 7 April 2010 16:58, Yanni Mac <li...@ruby-forum.com> wrote: >> extremely inefficient. > Ah! Sorry... missed that. > > Just a thought... can you be sneaky and add an accessor method to Click? > > # Click model > def count > read_attribute(:count).to_i rescue nil > end > > > No idea if it'll work... maybe worth a bash...
Thanks Michael, that got me thinking! This is a hack, but it still works for me because I can call it on one line. I am developing a reporting system where I convert an ActiveRecord object list to a table, so I really wanted to avoid hard coding something in each class. This allows me to create my list on one line and then pass it to my conversion method. Click.find(:all,:select=>"count(*) as click_count, date", :group=>"date").each{|c|c.click_count = c.click_count.to_i} I still want to figure out why count(*) does not return a number data type, but this will work for now. -- Posted via http://www.ruby-forum.com/. -- 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-t...@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.