我是Ruby和Rails的新手,在空闲时间自学。我最近在我的gemfile文件中添加了一些宝石,现在我的脚手架给了我错误-在StackOverflow上找不到另一个解决我问题的答案(如果我的搜索能力不能达到要求,请提前道歉)。>
宝石文件:
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'
这是我尝试生成支架时的错误:
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)
如您所见,当它进入脚手架一代的“ _form.html”部分时,似乎出现了问题。
我检查以确保对文件没有奇怪的权限。我怀疑这与Foreman(这是Heroku的事情)有关,或者与dotenv(这是本地开发所需的东西,所以我可以存储秘密)有关。我在其他地方发现了一些关于Rails 5.1的早期Beta版本的帖子,它们与Thor有问题,但是我什至不知道Thor的作用(这是某种依赖性),他们说该错误已在后续发行版中修复(例如,我正在使用5.2)。
我的另一种理论是,它与Jbuilder和json内容有关,这也是我的新手,甚至都不知道从哪里开始解决。
有什么想法吗?同时,我将不用脚手架就可以工作。
无论如何,谢谢您的时间!
谢谢您的时间!
更新!
好吧,我自己解决了这个问题,只想报告。因此,我忘记了我也无法安装Nokogiri。每当我运行“捆绑更新”时,我都会收到一条错误消息,指出我需要确保正确安装了Nokogiri的最新版本,然后才能继续。我忽略了这一点,因为我无法弄清楚。只需按照nokogiri.org上的说明并安装必要的库即可解决此问题:
sudo apt-get install build-essential补丁ruby-dev zlib1g-dev liblzma-dev
gem安装nokogiri
完成此操作后,我对自己说:“嗯,这可能是解决脚手架问题的方法。确实是。
答案 0 :(得分:0)
上面的详细信息,但是:
好吧,我自己解决了这个问题,只想报告。 因此,我忘记了我也无法安装Nokogiri。每当我 跑了“捆绑更新”,我得到一个错误,说我需要做 确保正确安装了最新版本的Nokogiri 继续。我忽略了这一点,因为我无法弄清楚。这个 只需遵循nokogiri.org上的说明即可解决,并且 安装必要的库:
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev gem install nokogiri
完成此操作后,我对自己说:“嗯,这可能是 解决脚手架问题的方法。”确实如此。