jviney / acts_as_taggable_on_steroids Goto Github PK
View Code? Open in Web Editor NEWTagging for Ruby on Rails
License: MIT License
Tagging for Ruby on Rails
License: MIT License
Class TagList (method #from, line 87) uses deprecated rails-method 'returning':
http://guides.rubyonrails.org/2_3_release_notes.html#objecttap-backport
It causes a critical fail on rails-3.0.0rc/ruby-1.8.7-p299.
Possible solutions are:
def from(source)
new.tap do |tag_list|
case source
...
def returning( obj )
return obj unless block_given?
if obj.respond_to? :tap
obj.tap { |*x| yield( *x ) }
else
yield( obj )
return obj
end
end
(need to say, I don't like this way and I think something better exists, but this way works for me).
Calling #tag_counts causes the creation of invalid SQL when using this with Rails 3. It turns out that the #scope method on ActiveRecord::Base no longer does the same thing as in Rails 2.3. (It was renamed from #named_scope for Rails 3.)
I made a temporary fix on my fork at http://github.com/fragility/acts_as_taggable_on_steroids/commit/3994188312ba7404f31aa70a997b2a8487868aa5 but it's kind of a cop-out.
Using tags in my URLs and want to have slugs for them, how do I do that without editing the model code in the plugin?
ruby: 1.8.7 REE
rails: 3.0.0.rc
steps to reproduce:
rails plugin install git://github.com/jviney/acts_as_taggable_on_steroids.git
rails generate acts_as_taggable_migration
Hi,
I have DEPRECATION WARNING: Object#returning has been deprecated in favor of Object#tap. (called from from at /opt/local/lib/ruby/gems/1.8/gems/acts_as_taggable_on_steroids-1.2/lib/tag_list.rb:87) with gem 1.2 and Rails 2.3..9, but I see the file, tag_list.rb, is different with github repository.
Updating your Gem is expected when?
Thanks
Line 139 of acts_as_taggable.rb calls scope(:find) which overwrites the standard find method in Rails 3, causing all subsequent calls to find() on that model to return a scope (relation).
I'm not familiar enough with the code to know what the scope call is supposed to be doing -- otherwise I'd submit a patch.
Hi, in my project I use this plugin but rails gives this warning everytime I run the server:
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
Is there a way to install this plugin according to new standards?
I have included this as a plugin and put
acts_as_taggable in my Post model, however still get the error
undefined local variable or method `acts_as_taggable'
do I have to include the original acts_as_taggable gem in my environment?
I have scoured the web and found alot of mentions of this error but no solution.
any ideas?
I need to implement a kill words feature so "kill words" wouldn't get tagged. Is this something you're interested in me contributing back?
DEPRECATION WARNING: Base#after_destroy has been deprecated, please use Base.after_destroy :method instead. (called from at /home/user/rails_app/vendor/plugins/acts_as_taggable_on_steroids/lib/tagging.rb:5)
I'm not sure the right change for this. I'm giving this a try for now, which doesn't give a warning:
---- tagging_old.rb 2010-09-06 17:48:31.460083461 -0700 ++++ tagging.rb 2010-09-06 17:47:52.440549426 -0700 @@ -2,7 +2,7 @@ belongs_to :tag belongs_to :taggable, :polymorphic => true - def after_destroy + after_destroy do |tag| if Tag.destroy_unused if tag.taggings.count.zero? tag.destroy
I referenced this page for the correct method:
http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
Postgres is complaining due to the order by Random() at the end of my query. it wants that included in the select clause inside "find_options_for_find_tagged_with". I can't figure out how to include this, and don't think I want to - it sounds like the result would be that the objects I return would no longer be dinstinct. See my post on Stackoverflow for a more clear explanation:
http://stackoverflow.com/questions/4721094/acts-as-taggable-on-steroids-query-failing-on-postgres
thanks! love this plugin.
Rails: 2.3.5
Plugin version: [17 Sep 08]
Model:
class BlogPost < ActiveRecord::Base
has_many :comments
acts_as_taggable
has_friendly_id :title, :use_slug => true
end
Trace:
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in `method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:815:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:815:in `validates_uniqueness_of'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:814:in `map'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:814:in `validates_uniqueness_of'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:468:in `validates_each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:465:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:465:in `validates_each'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in `evaluate_method'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in `run_callbacks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1098:in `valid_without_callbacks?'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:315:in `valid?'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1087:in `save_without_dirty!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/dirty.rb:87:in `save_without_transactions!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in `save!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in `save!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in `save!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1059:in `create!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/reflection.rb:179:in `create_association!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/has_many_through_association.rb:70:in `insert_record'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2143:in `with_scope'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/has_many_through_association.rb:70:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/has_many_through_association.rb:70:in `insert_record'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:119:in `<<'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:433:in `add_record_to_target_with_callbacks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:118:in `<<'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:116:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:116:in `<<'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:141:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:140:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:115:in `<<'
C:/Inetpub/rails_apps/frexwebify.com/vendor/plugins/acts-as-taggable-on-steroids/lib/acts_as_taggable.rb:182:in `save_tags'
C:/Inetpub/rails_apps/frexwebify.com/vendor/plugins/acts-as-taggable-on-steroids/lib/acts_as_taggable.rb:181:in `each'
C:/Inetpub/rails_apps/frexwebify.com/vendor/plugins/acts-as-taggable-on-steroids/lib/acts_as_taggable.rb:181:in `save_tags'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in `transaction'
C:/Inetpub/rails_apps/frexwebify.com/vendor/plugins/acts-as-taggable-on-steroids/lib/acts_as_taggable.rb:175:in `save_tags'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `evaluate_method'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:93:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in `run_callbacks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:344:in `callback'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:251:in `create_or_update'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2538:in `save_without_validation'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1078:in `save_without_dirty'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/dirty.rb:79:in `save_without_transactions'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:in `with_transaction_returning_status'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:228:in `with_transaction_returning_status'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:196:in `save'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:196:in `save'
C:/Inetpub/rails_apps/frexwebify.com/app/controllers/admin/blog_posts_controller.rb:13:in `create'
Params:
{"commit"=>"Submit",
"blog_post"=>{"intro"=>"123
",
"title"=>"1231",
"published_at(1i)"=>"2010",
"content"=>"123
",
"published_at(2i)"=>"1",
"tag_list"=>"hehe",
"published_at(3i)"=>"30"}}
To install the plugin in Rails 3:
rails plugin install git://github.com/jviney/acts_as_taggable_on_steroids.git
The readme needs to have a .rdoc extension for github to display it correctly. Here's a pull request to fix it - #25.
I found that :match_all => true did not seem to be working for me - I was getting the same result set as when I did not use it. I don’t know if there is a unique circumstance on my end that is causing the problem (I just imported data from a legacy database and there may have been some weirdness in the data that would not be present if the data had been generated by the plugin itself), or maybe there is an issue with the plugin. I changed line 90 of lib/acts_as_taggable.rb to this:
(SELECT COUNT(DISTINCT tags.id) FROM #{Tagging.table_name}
That seems to work for me.
The doc says to use the tag_list accessor as normal, but even with a cahced_tag_list column present, a query is being performed to get an object's tags.
Example:
posts/show
<%= @post.tag_list %>
=> SELECT tags
.* FROM tags
INNER JOIN taggings
ON tags
.id = taggings
.tag_id WHERE ((taggings
.taggable_id = 12345) AND (taggings
.taggable_type = 'Post'))
I would expect it to return the cached tag list instead. Caching does work as expected when editing an object, and no query is performed.
Using Rails 3.2
It seems in the Tag model that :name is not accessible, tried to override creating a file Tag.rb:
class Tag < ActiveRecord::Base
attr_accessible :name
end
but it did not solve the issue.
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.