Reputation: 12207
I have a working Rails project. I'm adding a feature that adds a secondary relationship between two tables. They have a primary join table, and I'm adding a second one for a different relationship:
in Clients:
has_and_belongs_to_many :reports, :join_table => 'reports_clients'
has_and_belongs_to_many :managed_reports, :class => :reports, :join_table => 'client_report_manager'
in Reports:
has_and_belongs_to_many :clients, :join_table => 'reports_clients'
has_and_belongs_to_many :client_managers, :class => :clients, :join_table => 'client_report_manager'
I'm getting the error above: 'block in assert_valid_keys': Unknown key: class (ArgumentError)
At least I'm pretty sure that that's where the error is... The reports_clients
relationship works fine. the new client_report_manager
is the thing that is breaking it, I think.
Upvotes: 2
Views: 745
Reputation: 33552
'block in assert_valid_keys': Unknown key: class (ArgumentError)
The problem is that class
is not a valid key here. It should be class_name
. Also the value for the class_name
should be the name of the class
has_and_belongs_to_many :managed_reports, :class_name => 'Report', :join_table => 'client_report_manager'
has_and_belongs_to_many :client_managers, :class_name => 'Client', :join_table => 'client_report_manager'
Upvotes: 2