2017-06-29 154 views
0

我試圖給出一個生成任何,它不會,這個錯誤出現,有時沒有出現,它會一直運行,並沒有出現。到底是怎麼回事?我是這個領域的新手。生成不生成代碼

[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# 
+0

'rails g scaffold用戶名電子郵件'適用於我。然而,這個警告意味着你正在運行帶有舊版Rails的Ruby的最新版本。升級Rails(或降級Ruby)可以解決這個問題。 – Stefan

+0

我該怎麼做?我已經嘗試過原始文檔,但我不知道該怎麼做......我不明白該怎麼做。 –

+0

我認爲值得讓Rbenv(我使用這個)或rvm(我在MacOSX上遇到了幾個與rvm相關的問題),以便管理你的ruby的東西。它們允許下載和安裝ruby版本,爲某些項目設置「全局」ruby版本和gem set,和/或本地ruby版本以及所需的gemset。我發現它安裝和使用非常緊張。 –

回答

0

我沒有永久解決它,但我找到了一個解決方案來規避錯誤。 當我給一個新的軌道,它生成的寶石文件中,將指定的軌道版本,我只是改變了產生的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升級我的導軌,所以我做這個「調整」。