Why Does Rails 4.2 + Responders Keeps Telling Me to Add Responders to the Gemfile

Why does Rails 4.2 + responders keeps telling me to add responders to the Gemfile?

The following worked for me using rails-api / active_model_serializers 0.8.3:

Remove

include ActionController::MimeResponds
include ActionController::ImplicitRender

Add

include ActionController::RespondWith

See this discussion on github.

Gem dependencies in Rails Engines

As you observe, the gem is included in your bundle whether it is in your application's Gemfile or not. The difference is that when Bundler.require is called during application initialisation it only auto requires the gem's in your application's Gemfile - not indirect dependencies.

If your gem requires the responders gem gem to be loaded then it should require it explicitly - for example at the top of my_api.rb

Ruby On Rails Devise gem conflict error

It looks like you are trying to use devise v4.2.1 gem with rails v5.1.0. It is not possible to do so at this moment as devise v4.2.1 has a runtime dependency of railties = <5.1, >=4.1.0 and rails v5.1.0 has a runtime dependency of railties = 5.1.0. End result is a version conflict which is what you are encountering. I would suggest you to downgrade to rails v5.0.2 in order to be able to use devise on your app. There shouldn't be any version conflicts once you do that.

Add `gem 'pg'` to your Gemfile and ensure its version is at the minimum required by ActiveRecord

When you create a rails 5 application with

rails new app-name -d postgresql

it will set postgres gem (pg) to 0.21 by default.

Possibly you've skipped this step when you started your project, and added pg on later stages. Let's rewind.

rails new without-db #defaults to sqlite3
cd without-db

Then I've edited my Gemfile replacing

gem 'sqlite3'

to

gem 'pg'

then

bundle install

Now, postgres gem version is 1.0.0. Edited my database.yml for connection credentials.Then some stuff to generate model, migration, controller etc. and push them to heroku.

$ rails g scaffold book title:string author:string genre:string description:string
...
$ rake db:create
...
$ rake db:migrate
...
$ heroku login
...
$ git init
...
$ heroku git:remote -a without-db-sample
...
$ git add .
...
$ git commit -m "initial commit"
...
$ git push heroku master
...
$ heroku run rake db:migrate
...
$ heroku open

Albeit I don't love this version of pg, it worked normally.

Then edited Gemfile again, replacing,

gem 'pg' 

to

gem 'pg', '~> 0.18'

then

$ bundle install
...
$ bundle show pg
/home/ziya/.rvm/gems/ruby-2.4.1/gems/pg-0.21.0
$ git status
...
$ git add .
...
$ git commit -m "change postgres version"
...
$ git push heroku master

It still works normally - https://without-db-sample.herokuapp.com/books



Related Topics



Leave a reply



Submit