At the ruby level, type is an alias of
class, too (sorta), so it's gonna have some major issues with that word.

Sent from my iPhone

On 30/01/2009, at 4:20 AM, Rob Biedenharn <[email protected]>  
wrote:

>
> 'type' is used by ActiveRecord to indicate Single Table Inheritance.
>
> That's probably tripping you up (esp. since changing the name
> eliminates the issue)
>
> On Jan 29, 2009, at 12:13 PM, Rasmus Nielsen wrote:
>
>>
>> Hi there,
>>
>> I have a Item-model that belongs to the ItemType-model. This works
>> fine:
>>
>> class Item < ActiveRecord::Base
>> belongs_to :item_type
>> end
>>
>> However, if I rewrite this to:
>>
>> class Item < ActiveRecord::Base
>> belongs_to :type, :class_name => "ItemType"
>> end
>>
>> ... i get the following in the console:
>>>> Item.first.type
>> => nil
>>
>> When looking at my log I can see that no query are sent to the
>> db-server. This does not work:
>> class Item < ActiveRecord::Base
>> belongs_to :blah, :class_name => "ItemType"
>> end
>>
>> However, this does:
>> class Item < ActiveRecord::Base
>> belongs_to :item_type, :class_name => "ItemType" # I know this does
>> not make sense
>> end
>>
>> Can anybody explain what's going on there? Ultimately I would like
>> to be
>> able to write Item.find(x).type.
>>
>> Thanks in advance! :-)
>>
>> - Rasmus
>> -- 
>> Posted via http://www.ruby-forum.com/.
>>
>>>
>
>
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to