[Nitro] Where to define Og relations
Robert Mela
rob at robmela.com
Wed Oct 3 08:21:20 EDT 2007
Some of the relation declarations are for the benefit of Og in schema
generation.
Others are for the benefit of Forms in generating form elements to bind
relations ( see the views in nitro/part/admin/og )
Arne Brasseur wrote:
> 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)
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rob.vcf
Type: text/x-vcard
Size: 116 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20071003/fd7e8ce9/attachment.vcf
More information about the Nitro-general
mailing list