Question: What if I had 3 Models that I wanted to connect. 

For example:

A user can have many different permissions for many different applications. 

So I need a table to store:

```
user_id
permission_id
application_id

```

Is that possible with has\_and\_belongs\_to\_many?

Thanks

Answer: 
I would do it with a has\_many :through.

```
class Upa < ActiveRecord::Base
  belongs_to :user 
  belongs_to :permission 
  belongs_to :application
end
class User < ActiveRecord::Base
  has_many :permissions, :through => :upas
  has_many :applications, :through => :upas
end
class Permission < ActiveRecord::Base
  has_many :users, :through => :upas
  has_many :applications, :through => :upas
end
class Application < ActiveRecord::Base
  has_many :permissions, :through => :upas
  has_many :users, :through => :upas
end

```

[examples of has\_many :through](http://blog.hasmanythrough.com/2007/1/15/basic-rails-association-cardinality)

Basically any sort of relationship that you can describe with a classical one to one, one to many and many to many relationships in relational databases can be described in ActiveRecord.
Yes, you can have has\_and\_belongs\_to\_many relationship. More help can be found here <http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html>