I am having an issue with a many to many relationship in Rails 3. The 3 models involved here are:

```
class Device < ActiveRecord::Base
  attr_accessible :name, :protocol, :address, :status, :room_id

  belongs_to :room

  has_many :device_abilities
  has_many :abilities, :through => :device_abilities
end

class Ability < ActiveRecord::Base
  attr_accessible :name

  has_many :device_abilities
  has_many :devices, :through => :device_abilities
end

class DeviceAbility < ActiveRecord::Base

  belongs_to :device
  belongs_to :ability
end

```

and I have the following in my seed file for testing:

```
device_abilities = DeviceAbility.create([
  { device_id: '1', ability_id: '1'},
  { device_id: '1', ability_id: '2'},
  { device_id: '1', ability_id: '3'},
  { device_id: '1', ability_id: '4'},
  { device_id: '1', ability_id: '5'},
  { device_id: '2', ability_id: '1'},
  { device_id: '2', ability_id: '2'},
  { device_id: '2', ability_id: '3'},
  { device_id: '2', ability_id: '4'},
  { device_id: '2', ability_id: '5'}
  ])

```

(the actual devices and abilities are also defined, and I can interact with them normally).

I am getting the unusual error when I attempt to do

```
def show
  @device = Device.find(params[:id])
  puts @device.abilities
end

```

(the puts is for debugging; I can also not use this if i put it into a variable). The error is:

```
undefined method `zero?' for nil:NilClass

```

Can anyone tell me where I am going wrong?

update:

as requested, the error trace:

```
app/controllers/devices_controller.rb:13:in `puts'
app/controllers/devices_controller.rb:13:in `puts'
app/controllers/devices_controller.rb:13:in `show'

```

and the schema is:

```
create_table "abilities", :force => true do |t|
    t.string   "name"
    t.datetime "created_at"
    t.datetime "updated_at"
end

create_table "devices", :force => true do |t|
    t.string   "name"
    t.string   "protocol"
    t.string   "address"
    t.boolean  "status"
    t.integer  "room_id"
    t.datetime "created_at"
    t.datetime "updated_at"
end

create_table "device_abilities", :force => true do |t|
    t.integer  "device_id"
    t.integer  "ability_id"
    t.datetime "created_at"
    t.datetime "updated_at"
end

```