[Nitro] Where to define Og relations
Arne Brasseur
arne at arnebrasseur.net
Wed Oct 3 02:46:54 EDT 2007
I just found out the hard way that defining a 'belongs_to' relation at
the beginning of the model class does not work. Once any managed
attributes are defined it does works.
require "og"
class Word
belongs_to WordList
attr_accessor :definitions, Array
end
gives:
./app/model/word.rb:3: undefined method `belongs_to' for Word:Class
(NoMethodError)
This:
class Word
attr_accessor :definitions, Array
belongs_to WordList
end
works fine.
Alternatively:
class Word
include Og::RelationDSL
belongs_to WordList
attr_accessor :definitions, Array
end
also works fine.
It's not clear to me if this is intended or not, has_many seems to work
fine once "og" is required. I haven't checked the other types of relations.
G, is this known/intended? If so it should be documented. Robert, you
could perhaps add this to your cheatsheets? Very nice work BTW! I'm
using them all the time now.
http://robmela.com/cheatsheets
(ab)
--
Arne Brasseur
http://www.arnebrasseur.net
arne at arnebrasseur.net
More information about the Nitro-general
mailing list