i'm trying to test using minitest but when running this file with
bin/rails test test/controllers/api/v1/blogs_api_controller_test.rb
But it gives this error
.rvm/gems/ruby-2.3.1/gems/railties-5.1.1/lib/rails/railtie/configuration.rb:95:in
method_missing': undefined methodweb_console' for
(NoMethodError) Did you mean? console
require 'test_helper'
class BlogsApiControllerTest < ActiveSupport::TestCase
test 'Get all Blogs' do
assert false
end
end
Rails version 5.1.1 Ruby 2.3.1
Gem File
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use Puma as the app server
gem 'puma', '~> 3.8.2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 3.2.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails', '~> 4.1.1'
# 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.6'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
gem 'kaminari', '~> 0.17.0'
gem 'bootsy', '~> 2.4'
gem 'searchkick', '~> 3.0.2'
gem 'devise', '~> 4.3.0'
gem 'omniauth-facebook', '~> 3.0.0'
gem 'omniauth-google-oauth2', '~> 0.4.1'
gem 'cancancan', '~> 1.15.0'
gem 'paperclip', '~> 5.0.0'
gem 'sitemap_generator', '~> 5.1.0'
gem 'jwt'
gem 'simple_command'
gem 'rack-cors', require: 'rack/cors'
# For admin panel ----------------
gem 'activeadmin', '~> 1.0.0'
# Below are for rails 5
# gem 'inherited_resources', github: 'activeadmin/inherited_resources'
# gem 'ransack', github: 'activerecord-hackery/ransack'
gem 'draper', '~> 3.0.1'
# ---------------------
group :development, :test do
gem 'pry'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.4.6'
end
group :development do
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.8'
# 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.1'
end
group :production do
gem 'pg', '~> 0.18.4'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Please put gem 'web-console' into your Gemfile's test section. You can change the following lines
group :development, :test do
gem 'pry'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.4.6'
end
with following
group :development, :test do
gem 'pry'
gem 'web-console'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.4.6'
end
And remove web-console from following lines
group :development do
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console' # remove this
Now run following command to update bundles
bundle install
Related
I'm trying to implement photo upload using DropzoneJS and Active Storage but at this point, my app throws undefined method 'image' for #<ActiveStorage::Attachment:0x00007fa51201dd80> error.
models/car.rb
index.html.erb
My Gemfile. Do i need to uncomment image-processing gem to enable and use?
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.5'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
#gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# 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.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
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]
end
group :development do
# Access an interactive console on exception pages or by calling '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'
#Provides better error page for Rails and other Rack apss.
gem 'better_errors', '~> 2.5', '>= 2.5.1'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'bootstrap', '~> 4.4.1'
gem 'devise', '~> 4.7', '>= 4.7.1'
gem 'jquery-rails'
gem 'omniauth', '~> 1.9'
gem 'omniauth-facebook', '~> 5.0'
#new gems
group :development, :production do
gem 'capistrano', '~> 3.11', require: false
gem 'capistrano-bundler', require: false
gem 'capistrano-rails', '~> 1.4', require: false
gem 'capistrano-passenger', '~> 0.2.0'
gem 'capistrano-rbenv', '~> 2.1', '>= 2.1.4', github: 'capistrano/rbenv', require: false
end
#gem 'capistrano', '~> 3.11'
#gem 'capistrano-rails', '~> 1.4'
#gem 'capistrano-passenger', '~> 0.2.0'
#gem 'capistrano-rbenv', '~> 2.1', '>= 2.1.4'
gem 'jquery-ui-rails', '~> 5.0'
This is a bit confusing as i'm new to this.
Am i suppose to create a Controller for Photos?
Do i need to add a certain gem too?
How do i fix this?
You don't need to create another model. All you need to make sure you add has_many_attached :photos to your model file and using url_for(self.photos[0]) for getting url. You can also go with self.photos[0].service_url
Edit after comments:
You are getting same NoMethodError because there is no image method defined on cover_photo. One way of correcting your can be like this
def cover_photo(size_x, size_y)
if self.photos.length > 0
self.photos[0].variant(resize_to_limit: [size_x, size_y]).processed.service_url
else
"blank.jpg"
end
end
Getting a funky error when trying to run my Rails server.
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (~> 5.2, >= 5.2.1)
trix (~> 0.11.1) was resolved to 0.11.1, which depends on
rails (> 4.1, < 5.2)
I tried checking if it was an issue with the version in my Gemfile and make sure it's the latest, but this didn't help. Also tried installing trix by itself, and updating my version of Ruby, but no luck. Any tips on how to move from here?
This is my Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2', '>= 5.2.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# 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 'mini_racer', platforms: :ruby
# 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', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
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]
end
group :development do
# Access an interactive console on exception pages or by calling '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
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'devise'
gem 'bulma-rails'
gem 'simple_form'
gem 'sidekiq'
gem 'carrierwave', '~> 1.0'
gem 'mini_magick', '~> 4.8'
gem 'stripe', '~> 3.11'
gem 'trix', '~> 0.11.1'
group :development, :test do
gem 'better_errors'
gem 'guard'
gem 'guard-livereload'
end
Appreciate any help. Thanks!
I have a rails app that works on my development box, i am putting it up on heroku and everything works fine except whenever I run a rake db.. command it does the command but at the end it gives me the following error:
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in require': cannot load such file -- /app/db:version (LoadError)
from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:inblock in require'
from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in load_dependency'
from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:inrequire'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:11:in
block in require_files'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:10:in
each'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:10:in
require_files'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.2/lib/rails/test_unit/minitest_plugin.rb:86:inplugin_rails_init'
from /app/vendor/bundle/ruby/2.4.0/gems/minitest-5.10.1/lib/minitest.rb:80:in
block in init_plugins'
from /app/vendor/bundle/ruby/2.4.0/gems/minitest-5.10.1/lib/minitest.rb:78:in
each'
from /app/vendor/bundle/ruby/2.4.0/gems/minitest-5.10.1/lib/minitest.rb:78:in
init_plugins'
from /app/vendor/bundle/ruby/2.4.0/gems/minitest-5.10.1/lib/minitest.rb:129:in
run'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.2/lib/rails/test_unit/minitest_plugin.rb:72:in run'
from /app/vendor/bundle/ruby/2.4.0/gems/minitest-5.10.1/lib/minitest.rb:62:in
block in autorun'
I have tried adding the gems railties and minitest into my gem file. I have deleted my heroku app and started from scratch again.
I have deleted the gemlock file and ran bundle install and bundle check
I have specified the ruby version in my gem file
Below is my gem file
source 'https://rubygems.org'
ruby "2.4.0"
gem 'rake', '~> 12.0'
gem 'railties', '~> 5.0', '>= 5.0.0.1'
gem 'minitest', '~> 5.10', '>= 5.10.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use mysql as the database for Active Record
#gem 'mysql2', '>= 0.3.18', '< 0.5'
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# 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.2'
# See https://github.com/rails/execjs#readme for more supported runtimes gem 'therubyracer', platforms: :ruby Use jquery as the JavaScript library
gem 'jquery-rails'
# 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
gem 'peddler', '~> 1.4.1'
gem 'nokogiri', '~> 1.6', '>= 1.6.8'
gem "pry-rails", group:"development"
gem 'chartkick', '~> 2.1', '>= 2.1.1'
gem "groupdate"
gem 'devise', '~> 4.2'
gem 'omniauth', '~> 1.3', '>= 1.3.1'
#required for devise
gem 'jquery-turbolinks'
#gem 'foundation-rails'
gem 'whenever', require: false
# export to excel
gem 'axlsx_rails', '~> 0.4.0'
gem 'axlsx', '2.1.0.pre'
gem 'roo'
gem 'rubyzip', '~> 1.1.0'
#gem 'zip-zip' #
#gem 'will_paginate', '~> 3.1.0'
#gem 'foundation-datepicker-rails'
gem 'will_paginate', '~> 3.1', '>= 3.1.5'
gem "wysiwyg-rails"
gem "font-awesome-rails"
gem 'stripe'
gem 'stripe_event', '~> 1.5', '>= 1.5.1'
#gem 'koudoku'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'bootstrap-datepicker-rails'
gem "bootstrap-switch-rails"
gem 'elasticemail', git: "git://github.com/klebervirgilio/elasticemail.git"
gem 'rails_admin', '~> 1.1.1'
gem 'cancancan', '~> 1.10'
gem 'ransack', github: 'activerecord-hackery/ransack'
gem 'sidekiq'
#gem 'sinatra', github: 'sinatra/sinatra'
gem 'rails_12factor', group: :production
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5' # was causing an error https://github.com/rails/rails/issues/24063 moved outside development group
# 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]
I am at a loss, thank you
The corrent syntax to run rake tasks on Heroku is heroku run rake db:migrate. In your command you missed run
As I can see you are using rails 5 and have 12factor gem. rails_12factor gem is not required for rails 5 deployment on heroku.
Follow heroku rails 5 deployment documentation and it should solve the issue.
Hope it helps.
Anytime I run $gem update or try to use $ gem install .... I receive this error:
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
Everything was working yesterday, I am not sure what happened. I have ran $ bundle install, $ bundle update, $ gem update.
If someone could point me in the right direction to get rails and gem working again, I would greatly appreciate you.
I am unable to gem install rack -v 2.0.1, nor, gem update rack, at once, the above error appears.
Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'activesupport', '~> 5.0', '>= 5.0.0.1'
gem 'rack', '~> 2.0', '>= 2.0.1'
gem 'rack-cache'
gem 'nokogiri', '~> 1.6.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# 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.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'hirb'
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# 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', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# 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
]
I am currently using Rails 4.2.5 for my project. In my gemfile, the way I install is :
gem 'awesome_nested_set'
Even though I install successfully, the problem is happened in the server.
Error:
undefined local variable or method `acts_as_nested_set'
only at production environment.
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'mysql2', '0.3.18'
# 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/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
#gem 'turbolinks'
gem 'awesome_nested_set', '3.0.2'
gem 'jquery-turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bcrypt', '~> 3.1.7'
gem 'devise'
gem 'rails_admin'
gem 'rb-readline'
gem 'unicorn'
gem 'capistrano', '>= 3'
gem 'capistrano-bundler'
gem 'capistrano-rbenv', github: "capistrano/rbenv"
gem 'capistrano-rails'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-oauth2', '~> 1.3.1'
# Use Unicorn as the app server
# gem 'unicorn'
gem 'wicked'
gem 'kaminari'
gem "simple_calendar", "~> 2.0"
gem 'bootstrap-sass'
gem 'chosen-rails'
gem 'mailboxer'
gem 'webpay'
gem 'unicorn'
gem 'gretel'
gem 'sitemap_generator'
gem 'stripe'
gem 'carrierwave'
gem 'rmagick'
gem 'i18n_generators'
# 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'
gem 'pry-rails'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
# gem 'spring'
end
[]# bundle show 'awesome_nested_set'
/usr/local/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/awesome_nested_set-3.1.1
It's in there..!