Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 5 issue: acts-as-taggable-on 3.5.0 has a dependency on activerecord < 5 #762

Closed
tirdadc opened this issue Jul 1, 2016 · 6 comments

Comments

@tirdadc
Copy link

tirdadc commented Jul 1, 2016

I was trying to upgrade an application to Rails 5, and after deleting my Gemfile.lock and re-running bundle install, I noticed that the dependency resolution yielded acts-as-taggable-on 2.1.1 instead of 3.5.0 (which I assume is the version that should have actual support for Rails 5).

Bundler could not find compatible versions for gem "activerecord":
  In snapshot (Gemfile.lock):
    activerecord (= 5.0.0)

  In Gemfile:
    acts-as-taggable-on (~> 3.5.0) was resolved to 3.5.0, which depends on
      activerecord (< 5, >= 3.2)

    rails (~> 5.0.0) was resolved to 5.0.0, which depends on
      activerecord (= 5.0.0)

How do I get this gem to work with Rails 5?

Bundler::GemRequireError: There was an error while trying to load the gem 'acts-as-taggable-on'.
Gem Load Error is: undefined method `attr_accessible' for #<Class:0x007fab83a14b28>
Did you mean?  attr_accessor
Backtrace for gem load error is:
/Users/tirdad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0/lib/active_record/dynamic_matchers.rb:21:in `method_missing'
/Users/tirdad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/acts-as-taggable-on-2.1.1/lib/acts_as_taggable_on/tag.rb:6:in `<class:Tag>'
/Users/tirdad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/acts-as-taggable-on-2.1.1/lib/acts_as_taggable_on/tag.rb:2:in `<module:ActsAsTaggableOn>'
/Users/tirdad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/acts-as-taggable-on-2.1.1/lib/acts_as_taggable_on/tag.rb:1:in `<top (required)>'
/Users/tirdad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
@emcoding
Copy link

emcoding commented Jul 2, 2016

I had the same message: Bundle could not find compatible versions for gem "activerecord".
First I removed the version of the gem in my gemfile. Bundler installed without complaints, but installed an older version.
Then I changed the line in my gemfile to:
gem 'acts-as-taggable-on', :git => 'https://github.com/mbleigh/acts-as-taggable-on'
Because it looks like the current master is at least partly updated for Rails 5.
Now you will get a message to rerun the migrations, just like any update.

I suppose you don't need to do my first step. I also removed the gemlock file, as suggested on Stack Overflow. Not sure if that step is needed either.
I am building a new app in Rails 5, not upgrading from an older version.

@tirdadc
Copy link
Author

tirdadc commented Jul 4, 2016

So that helped get past the initial hurdle, and I ran the new migration it mentioned to add indexes.

Now I can't seem to record new items that have tags as it results in a ROLLBACK:

Started POST "/products" for 127.0.0.1 at 2016-07-04 13:45:25 -0400
Processing by ReleasesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"5yYz3WHePpzitycC9GKPt0CEZ0LzTPK4JwEl52prPmtFcrSFTqr36bw5Jtj80gX4GqEd/ZNC5wTMi61ZKziP4g==", "release"=>{"artist"=>"Test 1", "title"=>"Test 2", "label"=>"Test 3", "price"=>"12", "format"=>"CD", "details"=>"", "cat_id"=>"", "stock"=>"0", "teaser"=>"", "visible"=>"1", "body"=>"", "release_date"=>"", "soundcloud"=>"", "delete_image"=>"0", "audio"=>"", "genre_list"=>"genre1, genre2", "status_list"=>""}, "redirect"=>"", "commit"=>"Create Release"}
   (0.2ms)  BEGIN
  SQL (0.3ms)  INSERT INTO `releases` (`artist`, `title`, `label`, `teaser`, `body`, `price`, `format`, `details`, `cat_id`, `audio`, `created_at`, `updated_at`, `soundcloud`, `visible`) VALUES ('Test 1', 'Test 2', 'Test 3', '', '', 12.0, 'CD', '', '', '', '2016-07-04 17:45:25', '2016-07-04 17:45:25', '', 1)
  ActsAsTaggableOn::Tag Load (0.6ms)  SELECT `tags`.* FROM `tags` WHERE (LOWER(name) = LOWER('genre1') OR LOWER(name) = LOWER('genre2'))
  ActsAsTaggableOn::Tag Exists (0.3ms)  SELECT  1 AS one FROM `tags` WHERE `tags`.`name` = 'genre1' LIMIT 1
  SQL (0.3ms)  INSERT INTO `tags` (`name`) VALUES ('genre1')
  ActsAsTaggableOn::Tag Exists (0.3ms)  SELECT  1 AS one FROM `tags` WHERE `tags`.`name` = 'genre2' LIMIT 1
  SQL (0.3ms)  INSERT INTO `tags` (`name`) VALUES ('genre2')
  ActsAsTaggableOn::Tag Load (0.4ms)  SELECT `tags`.* FROM `tags` INNER JOIN `taggings` ON `tags`.`id` = `taggings`.`tag_id` WHERE `taggings`.`taggable_id` = 853 AND `taggings`.`taggable_type` = 'Release' AND (taggings.context = 'genres' AND taggings.tagger_id IS NULL)
  ActsAsTaggableOn::Tag Load (0.3ms)  SELECT  `tags`.* FROM `tags` WHERE `tags`.`id` = 72 LIMIT 1
  ActsAsTaggableOn::Tagging Exists (0.4ms)  SELECT  1 AS one FROM `taggings` WHERE `taggings`.`tag_id` = 72 AND `taggings`.`taggable_type` = 'Release' AND `taggings`.`taggable_id` = 853 AND `taggings`.`context` = 'genres' AND `taggings`.`tagger_id` IS NULL AND `taggings`.`tagger_type` IS NULL LIMIT 1
   (0.6ms)  ROLLBACK

Not using tags or updating an already tagged item without changing the tags works fine.

EDIT: it seems this other issue has been reported in #742

@emcoding
Copy link

emcoding commented Jul 4, 2016

YES! It is working now.
@tirdadc I encountered the same rollback issue.
Following your lead to issue 742 and #720 : I forked the latest master and added the oneliner as suggested in #720.
I used my own fork as the source for the gem, and now it works: I can add tags, and show a tag_list in the view.

You can use my fork and add it in the gemfile instead:
gem 'acts-as-taggable-on', :git => 'https://github.com/F3pix/acts-as-taggable-on'

Hope it works for you too!

@adamdilek
Copy link

+1

@emcoding
Copy link

emcoding commented Jul 6, 2016

This one is solved with PR #720.

@seuros
Copy link
Collaborator

seuros commented Jul 17, 2016

A prerelease is available, please test it and report any bug.

@seuros seuros closed this as completed Jul 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants