Yes! That was the problem. Now the form for messages doesn't work. The
associations are:
Message
belongs_to :sender, :class_name => "User", :creator => true, :foreign_key =>
'sender_id'
has_many :recipients, :class_name => "User", :through => :message_recipients,
:accessible => true, :foreign_key => 'recipient_id'
has_many :message_recipients, :dependent => :destroy
User
has_many :received_messages, :class_name => "Message", :through =>
:message_recipients #possible I have to name class here?
has_many :message_recipients, :dependent => :destroy, :foreign_key =>
'recipient_id'
has_many :sent_messages, :class_name => "Message", :foreign_key => 'sender_id'
MessageRecipient
belongs_to :message
belongs_to :recipient, :class_name => "User", :foreign_key => 'recipient_id'
The generated form for messages looks like this:
<def tag="form" for="Message">
<form merge param="default">
<error-messages param/>
<field-list fields="subject, body, recipients, sender" param/>
<div param="actions">
<submit label="#{ht 'message.actions.save', :default=>['Save']}"
param/><or-cancel param="cancel"/>
</div>
</form>
</def>
But visiting /messages/new gives the error:
undefined method `klass' for nil:NilClass
app/views/taglibs/application.dryml:37:in `form__for_message'
app/views/taglibs/application.dryml:35:in `form__for_message'
app/views/taglibs/application.dryml:35:in `form__for_message'
app/views/taglibs/application.dryml:34:in `form__for_message'
app/views/taglibs/auto/rapid/pages.dryml:445:in `new_page__for_message'
app/views/taglibs/auto/rapid/pages.dryml:444:in `new_page__for_message'
app/views/taglibs/auto/rapid/pages.dryml:444:in `new_page__for_message'
app/views/taglibs/auto/rapid/pages.dryml:435:in `new_page__for_message'
app/views/taglibs/themes/clean/clean.dryml:2:in `page_without_a4e8f2708e51'
app/views/taglibs/themes/clean/clean.dryml:1:in `page_without_a4e8f2708e51'
app/views/taglibs/application.dryml:12:in `page_without_a46705120a36'
app/views/taglibs/application.dryml:11:in `page_without_a46705120a36'
app/views/taglibs/application.dryml:24:in `page_without_a0bbed2e9e5e'
app/views/taglibs/application.dryml:23:in `page_without_a0bbed2e9e5e'
app/views/taglibs/front_site.dryml:13:in `page'
app/views/taglibs/front_site.dryml:12:in `page'
app/views/taglibs/auto/rapid/pages.dryml:432:in `new_page__for_message'
app/views/taglibs/auto/rapid/pages.dryml:431:in `new_page__for_message'
The issue is definitely "recipients" in the field-list tag.
On Jun 12, 2011, at 9:14 PM, Matt Jones wrote:
>
> On Jun 12, 2011, at 8:59 PM, Mark Sobkowicz wrote:
>
>> I got it to give the same error with a much simpler setup. In a new hobo
>> app, I added a messages model. Then
>>
>> just adding this to the Message model and trying to run the migration gives
>> the same error:
>>
>> belongs_to :sender, :class => "User"
>
>
> Perhaps because the ActiveRecord option is :class_name?
>
> --Matt Jones
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en.