rials server error

错误1:ActiveRecord::StatementInvalid
/home/diudiugirl/.rvm/gems/ruby-2.1.3/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query’: Mysql2::Error: Table ‘ashelf_development.accounts’ doesn’t exist: SHOW FULL FIELDS FROM `accounts` (ActiveRecord::StatementInvalid) 
…..
解决方法:
database.yml中配置了三种环境,使用不同的数据库:development、test和production,而默认的是development环境。而在上述错误中未指定production环境,让我们使用rails s -e prodution来指定,又出现了如下的错误2。
错误2:ActiveRecord::AdapterNotSpecified
/home/diudiugirl/.rvm/gems/ruby-2.1.3/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection’: database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
解决方法:使用 RAILS_ENV=production rails s 命令来指定。
错误3:Errno::EADDRINUSE
/home/diudiugirl/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/socket.rb:206:in `bind’: Address already in use – bind(2) for 0.0.0.0:3000 (Errno::EADDRINUSE)
解决方法:已经有一个rails s在运行了。
错误4:ExecJS::RuntimeUnavailable
/home/diudiugirl/.rvm/gems/ruby-2.1.3/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in `autodetect’: Could not find a JavaScript runtime. See https://g`ithub.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
解决方法
按照错误提示ExecJS缺失runtime,查看链接https://g`ithub.com/sstephenson/execjs 可看到,ExecJS所支持的runtime:
而通过“ExecJS lets you run JavaScript code from Ruby. It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.”可以看到,ExecJS会自动选择一个最好的现有runtime,所以能装的gems都装一下吧。
有两种方法:一是,使用gem install therubyracer和sudo apt-get install nodejs。二是在Gemfile中加入gem ‘execjs’,并将“#gem ‘therubyracer’,  platforms: :ruby”前的注释去掉。

Leave a Reply

Your email address will not be published.