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

Draper relies on active_model/serializers/xml which is being removed in Rails 5 #697

Closed
audionerd opened this issue Oct 7, 2015 · 5 comments

Comments

@audionerd
Copy link

If you try using Draper on Rails 5, and you have spring enabled, you'll see this less-than-helpful error message:

./bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]

The most common rails commands are:
 generate    Generate new code (short-cut alias: "g")
 console     Start the Rails console (short-cut alias: "c")
 server      Start the Rails server (short-cut alias: "s")
[...]

If you disable spring:

~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/draper-2.1.0/lib/draper.rb:5:
  in `require': cannot load such file -- active_model/serializers/xml (LoadError)

In Rails 5, active_model/serializers/xml has been extracted into its own gem. So, a quick solution is to add the activemodel-serializers-xml gem to your Gemfile:

gem 'activemodel-serializers-xml', git: 'https://github.com/rails/activemodel-serializers-xml'
gem 'draper'

There is not yet a published release of activemodel-serializers-xml, hence the need to retrieve it from master in GitHub.

I was able to run Draper on Rails 5 with this solution, although I didn't run any of Draper's tests so I don't yet know what other issues might crop up.

@audionerd audionerd changed the title Draper relies on active_model/serializers/xml which is being removed in Rails 5 Draper relies on active_model/serializers/xml which is being removed in Rails 5 Oct 7, 2015
@jasnow
Copy link

jasnow commented Oct 21, 2015

This issue helped me - THANKS !!!

@olivierlacan
Copy link
Contributor

Bit shorter solution:

gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml'
gem 'draper'

This was referenced Apr 6, 2016
@seanlinsley
Copy link
Member

#752 has been merged and 3.0.0.pre1 released, which fixes this.

tute pushed a commit to norman/ambry that referenced this issue Jul 14, 2016
@tute
Copy link

tute commented Jul 22, 2016

We are about to publish in rubygems ambry v1, with no XML support (or dependency): https://github.com/norman/ambry/releases/tag/v1.0.0.

Thanks!

@fcostabr78
Copy link

great!

jessedoyle added a commit to amaabca/ama_layout that referenced this issue Feb 1, 2017
* We have to detect the rails version specified in the Gemfile.
  If we are using Rails 5, we have to point to a prerelease version
  of draper for compatibility. If not, we can use draper ~> 2.1.

SEE: drapergem/draper#697
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

6 participants