===================================================================== http://www.soen.info - source of the freshest software engineering
information on the net http://cusec.soen.info - software engineering conference
class Note < ActiveRecord::Base
acts_as_versioned do
belongs_to :user
end
end
This is a fairly new feature that I’ve added. I haven’t bothered to
update the gem or rdocs though, plugins are more agile. And I don’t
have that stuff all set up on my powerbook yet. I’m quite sure this
will require edge rails too.
Note: this creates an extension module that will be applied to both
Note and Note::Version. No need to call belongs_to on the model then.
That is great Rick. I can’t test it though because my application
for some odd reason does not like edge rails. I am always getting
unitialized constant. Any insight into that?
On 13-Feb-06, at 8:06 PM, Rick O. wrote:
The schema for my notes table is as follows:
end
User is not associated with versions. How can I associate it?
belongs_to :user
===================================================================== http://www.soen.info - source of the freshest software engineering
information on the net http://cusec.soen.info - software engineering conference
That is great Rick. I can’t test it though because my application
for some odd reason does not like edge rails. I am always getting
unitialized constant. Any insight into that?
This will work for me. My natural followup questions to this is
how can two versioned classes be linked together? Assuming Parent
has_many Children and a Child belongs_to Parent, I would want
Parent_version to have_many Children_Version and a Child_Version
to belong_to Parent_version. Is this easily doable ?
Regards,
Don
Sure, just reopen the class at the bottom of the file.
This will work for me. My natural followup questions to this is
how can two versioned classes be linked together? Assuming Parent
has_many Children and a Child belongs_to Parent, I would want
Parent_version to have_many Children_Version and a Child_Version
to belong_to Parent_version. Is this easily doable ?
class Thing < ActiveRecord::Base
acts_as_versioned do
belongs_to :user
end
end
I think I must be misunderstanding something, or doing something wrong.
When I modified my acts_as_versioned class (in my case “Thing”) as
described above, I get a NoMethodError: undefined method ‘belongs_to’
for #Module:0x2791c00.
Alternatively, I tried
class Thing < ActiveRecord::Base
belongs_to :user
end
Thing.versioned_class.class_eval do
belongs_to :user
end
and while there are no errors, eager-loading doesn’t happen when I’m
viewing one of my versions.
I’m using EdgeRails, and version 0.5.1 (Oct 5, 2006) of the AAV plugin.
If it makes a difference, my user model is provided by
ActsAsAuthenticated, and the related fields in my Thing model
(created_by, and updated_by) are being handled dynamically by the
userstamp plugin ( http://delynnberry.com/projects/userstamp/ ).
If there are any pertinent details that I’m leaving out, please let me
know! Any pointers anyone could offer would be very much appreciated!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.