To add to what Jonathan said, if you *retrieve* a resource without it's key, you get back an immutable resource too.
So if you have a Person model with a Serial id and you do something like: Person.all(:job => 'coder', :fields => [ :name ]) you will get back a Collection of immutable resources, because you've told it specifically to not include the key property (:id) cheers snusnu On Mon, Jan 10, 2011 at 16:39, Jonathan Stott <[email protected]> wrote: > Also, you will retreive an immutable resource if you define a Model > without a key. > > To check for this (and to initialize relationships), you should always > run DataMapper.finalize after defining all your models. > > Regards > Jon > > On 10 January 2011 15:23, Zhi-Qiang Lei <[email protected]> wrote: >> Dear All, >> >> Could anyone answer me when a resource should be immutable? And why? Thanks. >> >> Best regards, >> Zhi-Qiang Lei >> [email protected] >> >> -- >> You received this message because you are subscribed to the Google Groups >> "DataMapper" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/datamapper?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
