Search code examples
ruby-on-railsrubyacts-as-taggable-on

In Rails can i pass additional filter options in tagged_with method for acts-as-taggable-on?


I have an object called Course. I would like to provide tags on courses so that users can search/filter based on those tags.

I'm using the gem acts-as-taggable-on:

Course.tagged_with(params[:tag])

In this method can I pass additional filtering on Course columns/attributes i.e. where enabled = 'Y'?


Solution

  • Yes, .tagged_with should be chainable with other ActiveRecord queries:

    Course.tagged_with(params[:tag]).where(enable: "Y")