I'm relatively new to Ruby and Rails, been teaching myself in free time. I recently added a few gems to my gemfile, and now my scaffold is giving me errors--couldn't find another answer on StackOverflow that addressed my issue (apologies in advance if my search prowess isn't up to par).
Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Set up local .env file, require immediately
gem 'dotenv-rails', :require => 'dotenv/rails-now'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use postgresql as the database for Active Record
gem 'pg'
# 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 'duktape'
# 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'
# Mailcatcher for local mail debugging
gem 'mailcatcher'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15', '< 4.0'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# group :development, :test do
# gem 'foreman'
# end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
#Add Sprockets for installing gems
gem 'sprockets-rails', '>= 2.3.2', :require => 'sprockets/railtie'
#Add Bootstrap
gem 'bootstrap', '>= 4.1.3'
#Add JQuery (for Bootstrap)
gem 'jquery-rails', '~> 4.3.1'
#Add Chart.js for analytics
gem 'chart-js-rails', '~> 0.1.6'
#Add Devise for Authorization and Authentication
gem 'devise', '~> 4.4.3'
#Add Font Awesome Icons
gem 'font-awesome-sass', '~> 5.2.0'
#Mini-Magick for Image Processing (のし Generator)
gem 'mini_magick'
#Auto-upload setup for AWS S3
gem 'carrierwave'
gem 'carrierwave-google-storage'
# Easy Categories for Manual Articles
gem 'ancestry'
# CKEditor WYSIWYG text editor
gem 'simple_form'
gem 'ckeditor', github: 'galetahub/ckeditor'
# Sendgrid for confirmations, etc.
gem 'sendgrid-ruby'
And here's the error when I try to generate the scaffold:
rails generate scaffold Market namae:string address:string phone:string repphone:string fax:string cost:decimal excost:decimal history:string
invoke active_record
identical db/migrate/20181029224847_create_markets.rb
identical app/models/market.rb
invoke test_unit
identical test/models/market_test.rb
identical test/fixtures/markets.yml
invoke resource_route
route resources :markets
invoke scaffold_controller
identical app/controllers/markets_controller.rb
invoke erb
exist app/views/markets
conflict app/views/markets/index.html.erb
Overwrite /home/mudl/kanri/Dropbox/funabiki-online-h/app/views/markets/index.html.erb? (enter "h" for help) [Ynaqdh] n
skip app/views/markets/index.html.erb
identical app/views/markets/edit.html.erb
identical app/views/markets/show.html.erb
conflict app/views/markets/new.html.erb
Overwrite /home/mudl/kanri/Dropbox/funabiki-online-h/app/views/markets/new.html.erb? (enter "h" for help) [Ynaqdh] n
skip app/views/markets/new.html.erb
Traceback (most recent call last):
71: from bin/rails:4:in `<main>'
70: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
69: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
68: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
67: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
66: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
65: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
64: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
63: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
62: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<main>'
61: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
60: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
59: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
58: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
57: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
56: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands/generate/generate_command.rb:26:in `perform'
55: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators.rb:276:in `invoke'
54: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
53: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:232:in `dispatch'
52: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `invoke_all'
51: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `map'
50: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `each'
49: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `block in invoke_all'
48: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
47: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
46: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:133:in `_invoke_from_option_scaffold_controller'
45: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:266:in `_invoke_for_class_method'
44: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/shell.rb:68:in `with_padding'
43: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:277:in `block in _invoke_for_class_method'
42: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:115:in `invoke'
41: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:232:in `dispatch'
40: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `invoke_all'
39: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `map'
38: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `each'
37: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `block in invoke_all'
36: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
35: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
34: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:133:in `_invoke_from_option_template_engine'
33: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:266:in `_invoke_for_class_method'
32: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/shell.rb:68:in `with_padding'
31: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:274:in `block in _invoke_for_class_method'
30: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:274:in `instance_exec'
29: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb:26:in `block in <class:ScaffoldControllerGenerator>'
28: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:115:in `invoke'
27: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/group.rb:232:in `dispatch'
26: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `invoke_all'
25: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `map'
24: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `each'
23: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `block in invoke_all'
22: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
21: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
20: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/erb/scaffold/scaffold_generator.rb:18:in `copy_view_files'
19: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/erb/scaffold/scaffold_generator.rb:18:in `each'
18: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/erb/scaffold/scaffold_generator.rb:19:in `block in copy_view_files'
17: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/erb/scaffold/scaffold_generator.rb:19:in `each'
16: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/erb/scaffold/scaffold_generator.rb:21:in `block (2 levels) in copy_view_files'
15: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/named_base.rb:24:in `template'
14: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/named_base.rb:49:in `inside_template'
13: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/named_base.rb:25:in `block in template'
12: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions/file_manipulation.rb:115:in `template'
11: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions/create_file.rb:25:in `create_file'
10: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions.rb:95:in `action'
9: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions/create_file.rb:60:in `invoke!'
8: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions/empty_directory.rb:113:in `invoke_with_conflict_check'
7: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions/create_file.rb:72:in `on_conflict_behavior'
6: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions/create_file.rb:46:in `identical?'
5: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions/create_file.rb:53:in `render'
4: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/actions/file_manipulation.rb:116:in `block in template'
3: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/2.5.0/erb.rb:876:in `result'
2: from /home/mudl/.rbenv/versions/2.5.1/lib/ruby/2.5.0/erb.rb:876:in `eval'
1: from (erb):2:in `template'
(erb):2:in `concat': can't modify frozen String (FrozenError)
As you can see it seems to be having an issue when it gets to the "_form.html" part of the scaffold generation.
I checked to make sure there were no strange permissions on files. I suspect it has something to do with Foreman (which is a Heroku thing), or maybe dotenv (which is necessary for local development stuff, so I can store secrets). I found some posts elsewhere about previous beta versions of rails 5.1 have issues with Thor, but I don't even know what Thor does (it is some dependency) and they said that that bug was fixed on subsequent releases (e.g. I'm using 5.2 anyway).
My other theory is that it's related to Jbuilder and json stuff, which I'm also new to, and don't even know where to begin to tackle.
Any ideas? In the meantime I'm going to work without scaffolding.
Anyway, thank you for your time!
Thank you for your time!
Update!
Well, I solved the problem on my own, and just wanted to report back. So, I forgot I had had trouble installing Nokogiri as well. Whenever I ran "bundle update" I was getting an error that said I needed to make sure the latest version of Nokogiri was installed correctly before continuing. I ignored this, because I couldn't figure out out. This was solved by simply following the instructions at nokogiri.org and installing the necessary libraries:
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
gem install nokogiri
After I did this I thought to myself "Uh, duh, this is probably the solution to the scaffolding issue." Indeed it was.
Details above, but:
Well, I solved the problem on my own, and just wanted to report back. So, I forgot I had had trouble installing Nokogiri as well. Whenever I ran "bundle update" I was getting an error that said I needed to make sure the latest version of Nokogiri was installed correctly before continuing. I ignored this, because I couldn't figure out out. This was solved by simply following the instructions at nokogiri.org and installing the necessary libraries:
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev gem install nokogiri
After I did this I thought to myself "Uh, duh, this is probably the solution to the scaffolding issue." Indeed it was.