このrailscastに従って、3.0.10 の Rails アプリを 3.1.10 に移行しようとしましたが、Ryan の場合ほどスムーズにはいきませんでした。いくつかの gemset の依存関係の問題を解決した後、開発サーバーを起動しようとすると、次のエラーが発生しました。
[nw0.0.1master (migrate_to_31)]$ rails s
=> Booting WEBrick
=> Rails 3.1.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing': uninitialized constant Sass::Plugin (NameError)
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/initializers/active_admin.rb:2:in `<top (required)>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `each'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `block in <class:Engine>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `run'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `each'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/application.rb:96:in `initialize!'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/environment.rb:7:in `<top (required)>'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:3:in `block in <main>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `instance_eval'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `initialize'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `new'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `<main>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `eval'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `parse_file'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:200:in `app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:46:in `app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:304:in `wrapped_app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:254:in `start'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:70:in `start'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:54:in `block in <top (required)>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `tap'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:37:in `require'
from script/rails:37:in `<main>'
これが私の現在のGemfileです:
gem "pg"
gem 'pg_search'
gem 'rails', '3.1.10'
gem 'nokogiri', '1.5.5'
gem 'geocoder', '1.0.2'
gem 'devise', '1.5.3'
gem 'acts_as_api', '0.3.8'
gem 'paperclip', '~>2.4.1'
gem 'rake', '0.8.7'
gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git'
gem 'fb_graph', '1.9.5'
gem 'twitter', :git => 'https://github.com/sferik/twitter.git'
gem 'jquery-rails', '>= 1.0.12'
gem 'aws-s3'
gem 'remotipart', '~> 1.0'
gem 'activeadmin'
gem 'formtastic', '~> 2.1.0'
gem "browser"
gem "httparty"
gem "thin"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
group :production, :staging do
end
group :development do
gem 'rspec-rails'
gem 'annotate', '2.4.0'
gem 'faker', '0.3.1'
gem 'ruby-debug19', '0.11.6'
gem 'nifty-generators', '0.4.6'
gem 'silent-postgres'
end
group :test do
gem 'rspec'
gem 'webrat', '0.7.1'
gem 'factory_girl_rails'
gem "mocha", '0.9.12'
gem 'silent-postgres'
end
そして、application.rb でアセット パイプラインを有効にしました。これがapplication.rbです:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
module Nw001
class Application < Rails::Application
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# Note, the migration that I use to install the unaccented module for pgs requires SQL
# config.active_record.schema_format = :sql
#uncomment to force ssl on localhost
# config.middleware.insert_before ActionDispatch::Static, "Rack::SSL"
end
end
そして、config/environments ファイルに提案された追加を行いました。
初期化されていない定数 Sass::Plugin (NameError) を渡す方法はありますか?
Rails 3.1.0 も使用しようとしましたが、同じエラーがスローされます。またrails generate active_admin:assets
、active_admin アセットを更新するために実行しましたが、愛はありません。
アップデート
@andrew の提案で、新しいサンプル rails3.1.10 アプリケーションを作成しました。実際、私が行ったことは、以前の 3.1 用の gemset を削除することでした。rvm を使用して新しい gemset を作成します。Rails 3.1.10 を新しい gemset にインストールしました。その新しい 3.1 gemset の使用を開始しました。次に、新しい Rails 3.1.10 アプリを作成しました。アプリは期待どおりに実行されました。
次に、新しいアプリの gemfile を、3.1.10 に移行しようとしているアプリの gemfile に置き換えることで、さらに一歩進めました。いくつかの依存関係の問題に取り組み、sqlite3 gem を gemfile に再挿入した後、新しいテスト アプリは期待どおりに動作しました。
次に、テスト アプリの gemfile を、移行しようとしているアプリにコピーして戻し、まだ新しい 3.1 gemset を使用して、開発サーバーをロードしようとしました。それでもエラーが発生します。これは上記のエラーに似ていますが、多少異なります。見てみな:
[nw0.0.1master (master)]$ rails s
=> Booting WEBrick
=> Rails 3.1.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library': uninitialized constant Sass::Plugin (NameError)
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/initializers/active_admin.rb:2:in `<top (required)>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `each'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `block in <class:Engine>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `run'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `each'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/application.rb:96:in `initialize!'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/environment.rb:7:in `<top (required)>'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:3:in `block in <main>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `instance_eval'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `initialize'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `new'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `<main>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `eval'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `parse_file'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:200:in `app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:46:in `app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:304:in `wrapped_app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.8/lib/rack/server.rb:254:in `start'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:70:in `start'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:54:in `block in <top (required)>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `tap'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:37:in `require'
from script/rails:37:in `<main>'
この新しい情報は何かアイデアを引き起こしますか??? ありがとう!