Why can't Rails locate gems? - ruby-on-rails

I installed the geocoder gem in my gemfile like this:
gem 'geocoder', '~> 1.5.1'
Then I added this line to my model
class Place < ApplicationRecord
geocoded_by :address
end
I get this error:
undefined method `geocoded_by' for #<Class:0x00007f8b58b763b8>
Any idea why I'm getting this error? I figured installing the gem would be enough, but apparently, Rails can't locate the Geocoder library.
UPDATE #1 Here is my gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
gem 'rails', '~> 5.2.2'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'mini_racer', platforms: :ruby
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'impressionist', '~> 1.5', '>= 1.5.1'
gem 'geocoder', '~> 1.5', '>= 1.5.1'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'capybara', '>= 2.15'
gem 'rspec-rails'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
UPDATE #2
When I run gem list geocoder, This is what outputs:
*** LOCAL GEMS ***
geocoder (default: 1.5.1, 1.4.8, 1.4.7)
UPDATE #3 I don't think it's just geocoder...
I added this to my gemfile:
group :development do
# other gems are here, they're just not listed.
gem "better_errors"
gem "binding_of_caller"
end
However, I'm still getting regular errors. So now, not even the better gems error is being found!!!
UPDATE #4 Adding my Place Model and application record
class Place < ApplicationRecord
extend FriendlyId
friendly_id :name, use: :slugged
geocoded_by :address
end
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
UPDATE #5 Github issues recommendation
It was recommended to add this at the top of my model file:
extend Geocoder::Model::ActiveRecord
This was sort of a work-around solution, but not even this worked!
I get this error: uninitialized constant Place::Geocoder
UPDATE #6 | Temporary Fix
I downgraded gem 'geocoder', '~> 1.5.1' to gem 'geocoder', '1.5'
Any ideas?

I think that the problem is that necessary to do
bundle update .Always that you add gem in your Gemfile is necessary to do this.

Related

Rails 5.2.1 -> 5.2.2 upgrade on Heroku, deploy crashes with "Could not detect rake tasks"; Solidus 2.7

after upgrading and bundle install, I get this on deploy
Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
remote: ! rake aborted!
remote: ! LoadError: cannot load such file -- polyamorous/activerecord_5.2.2_ruby_2/join_association
gemfile OLD
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.2.5'
gem 'rails', '~> 5.2.1'
gem 'mysql2'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'nondestructive_migrations'
gem 'acts_as_paranoid', '~> 0.6.0'
gem 'sendgrid-ruby'
gem 'activerecord-session_store'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# gem 'spring'
# gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'solidus', '2.7.0'
gem 'solidus_auth_devise'
gem 'solidus_print_invoice' , github: 'solidusio-contrib/solidus_print_invoice'
gem 'solidus_gateway'
gemfile NEW (causes crash)
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.2.5'
gem 'rails', '~> 5.2.2'
gem 'mysql2'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'nondestructive_migrations'
gem 'acts_as_paranoid', '~> 0.6.0'
gem 'sendgrid-ruby'
gem 'activerecord-session_store'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# gem 'spring'
# gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'solidus', '2.7.0'
gem 'solidus_auth_devise'
gem 'solidus_print_invoice' , github: 'solidusio-contrib/solidus_print_invoice'
gem 'solidus_gateway'
this is fixed by bumping Solidus 2.7.0 to Solidus 2.7.1

My questions is about a file created in the command line not appearing in the project directory

I am currently building a ruby-on-rails app and attempted to create a migration through the command line by using:
rails g migration create_users username:string email:string password_digest:string --no-test-framework
The command line says that it successfully creates the migration and gives me the file name, which is db/migrate/20180907182240_create_users.rb. The problem is, it isn't showing up in my project directory on Atom. I restarted Atom and that didn't seem to do the trick.
I've also tried checking my git status and it comes up blank. There are no new files to commit, which leads me to believe that they may not be getting created to begin with.
If someone could help me find the files and/or if someone knows what is going wrong, I'd really appreciate the help! Thank you.
Here is my Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
gem 'rails', '~> 5.2.1'
gem 'sqlite3'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bcrypt', '~> 3.1.7'
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

spree_globalize was resolved to 3.1.0.beta when spree version is '~>3.3'

Is it possible to have model translation for Spree 3.3 (through spree_globalize) in Rails 5.1.3?
I followed the instructions but when I run bundle update, I get this error:
Bundler could not find compatible versions for gem "spree_i18n":
In snapshot (Gemfile.lock):
spree_i18n (= 3.3.0.rc1)
In Gemfile:
spree_i18n
spree_globalize was resolved to 3.1.0.beta, which depends on
spree_i18n (~> 3.1.0.beta)
And my Gemfile is
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.1.3'
gem 'sqlite3'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'spree', '~> 3.3.0.rc1'
gem 'spree_auth_devise', '~> 3.3'
gem 'spree_gateway', '~> 3.3'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_globalize', github: 'spree-contrib/spree_globalize', branch: 'master'

Rails 5 gem database_cleaner not find

I'm not new to rails but was a long time I didn't used it. Today was trying to build something and get this.
I try to run a standard
rails g migration add_user_id_to_posts user:references
And I always get this message in the terminal
Could not find database_cleaner-1.5.3 in any of the sources
Run `bundle install` to install missing gems.
But when I check in the Gemfile I have
source 'https://rubygems.org'
gem 'rails', '>= 5.0.0.rc1', '< 5.1'
gem 'pg', '~> 0.18'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks', '~> 5.x'
gem 'jbuilder', '~> 2.0'
gem 'responders', '~> 2.2'
gem 'devise', '~> 4.1', '>= 4.1.1'
group :development, :test do
gem 'byebug', platform: :mri
gem "rails-controller-testing", :git => "https://github.com/rails/rails-controller-testing"
gem "rspec-rails", "3.5.0.beta3"
end
group :development do
gem 'web-console'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'capybara', '~> 2.7', '>= 2.7.1'
gem 'database_cleaner', '~> 1.5.3'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
I try everything I find in the net. I deleted my Gemfile.lock and do bundle install again. I install the new version of ruby the 2.3.1.
But I can't figured out what to do. If someone can help me with this, would be appreciate.
Find the solution with the help of someone on Slack. I got my spring always running so I have just need to do spring stop and everything work like a charm after.
Thank you all for the help.

error parsing 'Gemfile', unexpected <<, [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I started a new rails project yesterday and everything worked fine. When I tried to run rails server or bundle install.
[!] There was an error parsing Gemfile: syntax error, unexpected <<,
expecting end-of-input - <<<<<<< HEAD ^. Bundler cannot continue.
# from /home/jhyatt/code/portfolio/Gemfile:10 #
------------------------------------------- # # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
<<<<<<< HEAD # gem 'rails', '~> 5.1.3'
Gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
<<<<<<< HEAD
gem 'rails', '~> 5.1.3'
=======
gem 'rails', '~> 5.1.1'
>>>>>>> 7eea851168152eafdda270b0524cef1d563dc203
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
<<<<<<< HEAD
#Bootstrap-sass
gem 'bootstrap-sass', '~> 3.3.6'
=======
>>>>>>> 7eea851168152eafdda270b0524cef1d563dc203
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Clean your Gemfile, removing the merge conflicts and try again. Also verify the Rails version you need:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.1.3'
gem 'sqlite3'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Resources