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
How to Split Routes.Rb into Smaller Files
In Ruby, How to Get Instance Variables in a Hash Instead of an Array
Why Does Ruby Builder::Xmlmarkup Add Inspect Tag to Xml
How to Override [] Brackets in Ruby
Is It Ever Necessary to Use 'Chomp' Before Using 'To_I' or 'To_F'
Capistrano and API Keys in Env Variables
How to Get Http Headers Before Downloading with Ruby's Openuri
Undefined Method (Nomethoderror) Ruby
How to Do String Comparison in Ruby
How to Get Long Filename from Argv
Execjs and Could Not Find a JavaScript Runtime
Rails 3.1 Load CSS in Particular Order
Skip/Disable Force_Ssl for Particular Controller in Rails
How to Remove Duplicates in a Hash in Ruby on Rails