Having a class
class Recipe < ActiveRecord
def initialize super() @someingredients =[“salt”] end
end
It appears that
Recipe.find(:all)
returns recipes who haven’t been ‘initialized’
How do you setup a suitable initial state when using these finders?
Best,
Y
On Mar 26, 12:26 pm, Yajiv [email protected] wrote:
It appears that Recipe.find(:all) returns recipes who haven’t been ‘initialized’ How do you setup a suitable initial state when using these finders?
ActiveRecord uses allocate instead of initialize when you find a records from the database. It does this for performance reasons and also for data integrity.
Please see http://gr-ruby.org/2006/1/18/activerecord-instantiation-magic
Zach
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.