生成不生成代码
问题描述:
我试图给出一个生成任何,它不会,这个错误出现,有时没有出现,它会一直运行,并没有出现。到底是怎么回事?我是这个领域的新手。生成不生成代码
[email protected]:~/Projeto/Projeto_testes/teste_projeto_generator# rails g scaffold User name email
/usr/lib/ruby/vendor_ruby/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
/usr/lib/ruby/vendor_ruby/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
[email protected]:~/Projeto/Projeto_testes/teste_projeto_generator#
答
我没有永久解决它,但我找到了一个解决方案来规避错误。 当我给一个新的轨道,它生成的宝石文件中,将指定的轨道版本,我只是改变了产生的Gemfile,我“创造”的一个:
source 'https://rubygems.org'
gem 'openssl', '2.0.4'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', github: 'rails/rails', branch: '4-2-stable'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# 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 'rails-i18n', '~> 4.0.0'
# 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'
# 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'
# Use Unicorn as the app server
# gem 'unicorn'
# 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'
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
我不能使用rbenv也不rvm升级我的导轨,所以我做这个“调整”。
'rails g scaffold用户名电子邮件'适用于我。然而,这个警告意味着你正在运行带有旧版Rails的Ruby的最新版本。升级Rails(或降级Ruby)可以解决这个问题。 – Stefan
我该怎么做?我已经尝试过原始文档,但我不知道该怎么做......我不明白该怎么做。 –
我认为值得让Rbenv(我使用这个)或rvm(我在MacOSX上遇到了几个与rvm相关的问题),以便管理你的ruby的东西。它们允许下载和安装ruby版本,为某些项目设置“全局”ruby版本和gem set,和/或本地ruby版本以及所需的gemset。我发现它安装和使用非常紧张。 –