I am contributing one of the ruby on rails application over GitHub where I faced the following scenario:

I am having following models which I want to convert to make polymorphic:

```
class Comment < ActiveRecord::Base
  belongs_to :team
  belongs_to :project
end

class Team < ActiveRecord::Base
  has_many :comments
end

class Project < ActiveRecord::Base
  has_many :comments, -> { order('created_at DESC') }, dependent: :destroy
end

```

I made following changes to make it polymorphic:

Perform database change to removed team\_id, project\_id and added commentable\_id and commentable\_type to comments table.

Modifications in models as described within rails guides:

```
class Comment < ActiveRecord::Base
  belongs_to :commentable, polymorphic: true
end

class Team < ActiveRecord::Base
  has_many :comments, as: :commentable
end

class Project < ActiveRecord::Base
  has_many :comments, as: :commentable, -> { order('created_at DESC') }, dependent: :destroy
end

```

While I use it with default scope, It doesn't allow me to use with default scope and gives error in below line in Project Model:

```
has_many :comments, as: :commentable, -> { order('created_at DESC') }, dependent: :destroy

```

I am getting following error on my browser:

[![enter image description here](https://i.stack.imgur.com/OSz5i.png)](https://i.stack.imgur.com/OSz5i.png)

Any help would be appreciated. Thanks in Advance!