Note that there are some explanatory texts on larger screens.

plurals
  1. PORails has_and_belongs_to_many
    primarykey
    data
    text
    <p>I am trying to set up as has_and_belongs_to_many relationship in my rails application, between an Employee model and a NetworkDrive model.</p> <p>In employee.rb I specified</p> <pre><code>has_and_belongs_to_many :network_drives&lt;/code&gt; </code></pre> <p>and in network_drive.rb...</p> <pre><code>has_and_belongs_to_many :employee&lt;/code&gt; </code></pre> <p>However, it seems to be generating model attributes like ":network_drife_ids" instead of ":network_drive_ids", which is giving me errors like</p> <p><code>uninitialized constant Employee::NetworkDrife</code></p> <p>which is accurate, considering the model is called NetworkDrive, not NetworkDrife.</p> <p>Sorry if this is a repeat question, but I wasn't sure how to search for this problem. I tried several solutions provided by questions about HABTM relationships on here, but to no avail.</p> <p>Update: Here's the whole error, after trying to change it to as has_many :through relationship.</p> <pre><code>NameError: uninitialized constant EmployeeItRequest::EmployeeItRequestDrife from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/inheritance.rb:111:in `compute_type' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/reflection.rb:172:in `klass' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/reflection.rb:216:in `association_primary_key' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/associations/has_many_association.rb:104:in `foreign_key_present?' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/associations/association.rb:165:in `find_target?' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/associations/collection_association.rb:332:in `load_target' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/associations/collection_proxy.rb:44:in `load_target' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/associations/collection_proxy.rb:87:in `method_missing' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.7/lib/rails/commands/console.rb:47:in `start' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.7/lib/rails/commands/console.rb:8:in `start' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.7/lib/rails/commands.rb:41:in `&lt;top (required)&gt;' from script/rails:6:in `require' from script/rails:6:in `&lt;main&gt;' </code></pre> <p>Update: Result of NetworkDrive.tableize</p> <pre><code>NoMethodError: undefined method `tableize' for #&lt;Class:0x0000000229fef8&gt; from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.7/lib/active_record/dynamic_matchers.rb:50:in `method_missing' from (irb):1 from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.7/lib/rails/commands/console.rb:47:in `start' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.7/lib/rails/commands/console.rb:8:in `start' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.7/lib/rails/commands.rb:41:in `&lt;top (required)&gt;' from script/rails:6:in `require' from script/rails:6:in `&lt;main&gt;' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload