jackdempsey / acts_as_commentable

The ActiveRecord acts_as_commentable plugin
http://juixe.com/svn/acts_as_commentable/
MIT License
834 stars 178 forks source link

Supply options to 'has_many' join #52

Closed pareeohnos closed 10 years ago

pareeohnos commented 10 years ago

Currently, acts_as_commentable assumes that your model is called Comment and provides no way of changing this.

This pull request allows you to provide options to the acts_as_commentable method that will be given to the has_many method internally. This way, you can set any of the options that has_many accepts as if you were calling it directly. This does not break support for the roles either, and requires no change to existing code so should not cause any issues in version upgrades.

Whilst I didn't create this directly to solve the issue, this does in fact solve the closed issue #25.

This PR also complements PR #51, as the gemspec file was still referencing the USEGA file and not the renamed USAGE file, causing it to give a warning about an invalid gemspec.

ikeqiao commented 10 years ago

it doesn't work using this code

acts_as_commentable :public, :private, { class_name: 'SampleComment' }

error message as follow:

SELECT "comments".id FROM "comments" WHERE "comments"."commentable_id" = ? AND "comments"."commentable_type" = ? AND "comments"."role" = 'public' [["commentable_id", 6], ["commentable_type", "Sample"]] SQLite3::SQLException: no such column: comments.role: SELECT "comments".id FROM "comments" WHERE "comments"."commentable_id" = ? AND "comments"."commentable_type" = ? AND "comments"."role" = 'public'