User:
has_many :received_messages, :class => "Message", :through => :message_recipients, :accessible => true
has_many :message_recipients, :dependent => :destroy, :accessible => true, :foreign_key => 'recipient_id'
has_many :sent_messages, :class => "Message", :foreign_key => 'sender_id', :accessible => true
Message:
belongs_to :sender, :class => "User", :creator => true, :foreign_key => 'sender_id'
has_many :recipients, :class => "User", :through => :message_recipients, :accessible => true
has_many :message_recipients, :dependent => :destroy, :accessible => true
MessageRecipient: (join model)
belongs_to :message
belongs_to :recipient, :class => "User", :foreign_key => 'recipient_id'
I set this up, then ran hobo g migration (hobo 1.3 pre31) here is the beginning of the trace:
Hobo Command Line Interface 1.3.0.pre31
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.7/lib/active_support/core_ext/hash/keys.rb:43:in `assert_valid_keys': Unknown key(s): class (ArgumentError)
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.7/lib/active_record/associations.rb:1774:in `create_belongs_to_reflection'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.7/lib/active_record/associations.rb:1220:in `belongs_to'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.7/lib/active_record/autosave_association.rb:137:in `belongs_to_without_hobo_permission_check'
from /Library/Ruby/Gems/1.8/gems/hobo-1.3.0.pre31/lib/hobo/model/permissions.rb:110:in `belongs_to_without_accessible'
from /Library/Ruby/Gems/1.8/gems/hobo-1.3.0.pre31/lib/hobo/model/accessible_associations.rb:125:in `belongs_to_without_creator_metadata'
from /Library/Ruby/Gems/1.8/gems/hobo-1.3.0.pre31/lib/hobo/model.rb:159:in `belongs_to_without_test_methods'
from /Library/Ruby/Gems/1.8/gems/hobo-1.3.0.pre31/lib/hobo/model.rb:163:in `belongs_to_without_field_declarations'
from /Library/Ruby/Gems/1.8/gems/hobo_fields-1.3.0.pre31/lib/hobo_fields/model.rb:93:in `belongs_to'
from /Users/mark/Documents/Hobo/class_management/app/models/message.rb:10
line 10 in message.rb is the belongs_to line.
Any ideas where I'm going wrong?
just adding this to the Message model and trying to run the migration gives the same error:
belongs_to :sender, :class => "User"
> 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
undefined method `klass' for nil:NilClassapp/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'I think message_recipients needs to be part of the form because the relationship goes through it.
--
I think message_recipients needs to be part of the form because the relationship goes through it.
--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/hobousers/-/ojYvyP71MT0J.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.