Factory girl with Rails 4.0 - ruby-on-rails

Just installed via RVM Ruby 2.0.0 and Rails 4.0.0. Started a new project and when tried to add the gem 'factory-girl-rails', and run bundle install, I got this error:
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Could not find gem 'factory-girl-rails (~> 4.2.1) ruby' in the gems available on this machine.
Any thoughts why can this be happening?

You need to change those dashes to underscores:
gem 'factory_girl_rails', '4.2.1'

factory_girl_rails does not seems to be available for rails higher then version 3.2.11
https://github.com/thoughtbot/factory_girl_rails#rails

Related

Error using devise_token_auth gem Rails 7

So I'm trying to generate a token for my Rails 7 app with devise_token_auth and I found this gem but I get this error and I understand that the gem is no longer updated:
Fetchings gem metadata from https://rubygems.org/...........
Resolving dependencies....
Bundler could not finde compatible versions from gem "rails":
In Gemfile:
rails (~> 7.0.1)
devise_token_auth was resolved to 0.1.21.alpha2, which depends on
rails (~> 4.1.4)
So what can I do about it?
Are there more gems like devise_token_auth? I can fix it without chainging my Rails version?
Thanks!
The latest version of devise_token_auth on rubygems (1.2.0) doesn't support rails 7, but the latest code on GitHub does support rails 7.
Try adding the gem like this
gem 'devise_token_auth', '>= 1.2.0', git: "https://github.com/lynndylanhurley/devise_token_auth"

RailsApps mysql2 gem version error with Rails 5.2.1

I am facing a mysql2 gem version error while trying to create a new RailsApps example application using Rails Composer. For example, while creating a rails-devise-roles example with the following command:
$ rails new rails-devise-roles -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
The error is:
Error loading the 'mysql2' Active Record adapter. Missing a gem it depends on? can't activate mysql2 (< 0.6.0, >= 0.4.4), already activated mysql2-0.3.21. Make sure all dependencies are added to Gemfile. (Gem::LoadError)
The messages on the console indicate mysql2 version 0.3.21 is pulled in
run bundle install --without production from "."
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
...................
Using mysql2 0.3.21
The generated Gemfile has
gem 'mysql2', '~> 0.3.18'
I am using ruby 2.5.3 and Rails 5.2.1

Heroku, bundler fails on missing dependencies

I have had trouble recently trying to deploy my rails app on Heroku. In the past, I had deployed apps on Heroku with no problem, but Heroku does not support ruby 2.0.0 anymore. They suggest adding ruby "2.2.4" to the Gemfile, which is what I did. The beginning of my Gemfile is as follows:
source 'https://rubygems.org'
ruby "2.2.4"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use pg as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
...
So, I have run bundle install with version 1.7.8 on my computer with no problem. I can even run my app in production mode. However, when I try to deploy the app on Heroku, I get this:
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.2.4
-----> Installing dependencies using bundler 1.11.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Installing i18n 0.7.0
Installing minitest 5.4.3
Installing json 1.8.3 with native extensions
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing erubis 2.7.0
Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
section: 'mini_portile2'
Bundler Output: Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Installing i18n 0.7.0
Installing minitest 5.4.3
Installing json 1.8.3 with native extensions
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing erubis 2.7.0
Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
section: 'mini_portile2'
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app
Any help is greatly appreciated.
I'd suggest deleting your Gemfile.lock, running bundle install again locally, committing the new Gemfile.lock to your git repository and then try your git push heroku master again.
I had the same problem and what I did was I updated Ruby 2.2.4 in my system and restarted terminal, then followed these steps:
bundle install
bundle update
git push heroku
( it’s a good idea to update the gems with bundle update to make sure the versions match)
The problem is that you only changed the Ruby version number in the Gemfile, but did not recreate a valid Gemfile.lock. This leads to a Gemfile.lock that contains Gems in versions that are not compatible with Ruby 2.2.4.
If you change something in the Gemfile then you have to update or recreate the Gemfile.lock with the same Ruby version before pushing to Heroku.
I suggest to use a Ruby version manager (like rbenv or RVM) to be able to run multiple versions of Ruby on your development machine. Then update the Ruby version in your application by changing the Ruby version in Gemfile (for Heroku) and .ruby-version (for your local environment). Both version must match.
Once that is done, run bundle install to update the Gemfile.lock or (when there were major updates or you just want to ensure that you use the latest versions) run bundle update to recreate the Gemfile.lock.

ruby gem error: Could not find gem 'logstash-devutils (>= 0) x64-mingw32'

On Windows 7, I'm following the steps in this tutorial from elastic
When I use the command bundle install I get the following error
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Could not find gem 'logstash-devutils (>= 0) x64-mingw32' in any of the gem
sources listed in your Gemfile or available on this machine.
and the following is my Gemfile
source 'https://rubygems.org'
gemspec
Kindly note that when I used the command gem list I can find the gem jquery-rails listed there
I had the same issue, and I believe this will fix the problem. In a nutshell, logstash-devutils needs jruby, so trying to use regular ruby won't work.
Could not find gem 'logstash-devutils (>= 0) ruby' in any of the gem sources
You have to add gem 'logstash-devutils', '~> 0.0.10' to your gemfile

OmniAuth bundle install error

I'm trying to use omniauth with a new project. I'm using it on other projects on my computer with no issues. 'gem list' confirms:
rails 3.2.9
omniauth 1.1.4
Everything is fine until I bundle install, at which point I get this error message:
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Could not find gem 'ominiauth (>= 0) ruby' in the gems available on this machine.
Here is my Gemfile:
source 'https://rubygems.org'
gem 'rails'
gem 'ominiauth'
You misspelled omniauth as ominiauth.

Resources