在生产模式下启动rails app时设计问题

时间:2016-05-22 12:51:11

标签: ruby-on-rails devise

我的服务器上有一个rails应用程序,当我执行public class Lot { public List<Lot> getAllLot(string query) { dao.getConnection() ; // Créer une liste pour stockerle résultat List<Lot> list = new List<Lot> () ; // ouvre la connection if (dao.openConnection()== true) { MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;database=pharmacie;uid=root;pwd=sqlServer12;"); // créer la commande MySqlCommand cmd = new MySqlCommand (query, connection); // Créer un data reader et executer la commande dao.getConnection() ; // *** The error is "Connection must be valid and open." MySqlDataReader reader = cmd.ExecuteReader(); // I get error here // lis les données et les stock dans la liste while (reader.Read()) { list.Add(new Lot { numLot = reader.GetString (0), dateFabrication = reader.GetDateTime(1), dateLivraison = reader.GetDateTime(2), datePeremption = reader.GetDateTime(3) }); } reader.Close(); dao.closeConnection(); } return list; } } 时运行正常,但当我运行rails s -b domain.namerails s -b domain.name -e production时出现以下错误。

RAILS_ENV=production rails s -b domain.name修改

这是导致错误的文件:

=> Booting Puma => Rails 4.2.6 application starting in production on http://domain.name:3000 => Run 'rails server -h' for more startup options => Ctrl-C to shutdown server Exiting /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:244:in 'rescue in load_dependency': /home/deploy/appname/app/controllers/users/confirmations_controller.rb:2: unknown regexp options - cfrat (SyntaxError) /home/deploy/appname/app/controllers/users/confirmations_controller.rb:7: unknown regexp options - cfrat /home/deploy/appname/app/controllers/users/confirmations_controller.rb:12: unknown regexp options - cfrat /home/deploy/appname/app/controllers/users/confirmations_controller.rb:13: syntax error, unexpected keyword_def, expecting ':' def show ^ /home/deploy/appname/app/controllers/users/confirmations_controller.rb:27: syntax error, unexpected keyword_end, expecting end-of-input from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:237:in 'load_dependency' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in 'require' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:360:in 'require_or_load' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:317:in 'depend_on' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:233:in 'require_dependency' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:472:in 'block (2 levels) in eager_load!' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in 'each' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in 'block in eager_load!' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in 'each' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in 'eager_load!' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:346:in 'eager_load!' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in 'each' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in 'block in <module:Finisher>' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in 'instance_exec' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in 'run' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in 'block in run_initializers' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:228:in 'block in tsort_each' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:350:in 'block (2 levels) in each_strongly_connected_component' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:431:in 'each_strongly_connected_component_from' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:349:in 'block in each_strongly_connected_component' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:347:in 'each' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:347:in 'call' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:347:in 'each_strongly_connected_component' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:226:in 'tsort_each' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/tsort.rb:205:in 'tsort_each' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in 'run_initializers' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:352:in 'initialize!' from /home/deploy/appname/config/environment.rb:5:in '<top (required)>' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in 'require' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in 'block in require' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in 'load_dependency' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in 'require' from /home/deploy/appname/config.ru:3:in 'block in <main>' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in 'instance_eval' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in 'initialize' from /home/deploy/appname/config.ru:in 'new' from /home/deploy/appname/config.ru:in '<main>' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in 'eval' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in 'new_from_string' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in 'parse_file' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/server.rb:299:in 'build_app_and_options_from_config' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/server.rb:208:in 'app' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/server.rb:61:in 'app' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/server.rb:336:in 'wrapped_app' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/server.rb:272:in 'start' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/server.rb:80:in 'start' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:80:in 'block in server' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in 'tap' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in 'server' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in 'run_command!' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in '<top (required)>' from /home/deploy/appname/bin/rails:9:in 'require' from /home/deploy/appname/bin/rails:9:in '<top (required)>' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in 'load' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in 'call' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/client/command.rb:7:in 'call' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/client.rb:30:in 'run' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/bin/spring:49:in '<top (required)>' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/binstub.rb:11:in 'load' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/binstub.rb:11:in '<top (required)>' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 'require' from /home/deploy/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 'require' from /home/deploy/appname/bin/spring:13:in '<top (required)>' from bin/rails:3:in 'load' from bin/rails:3:in '<main>'

/home/deploy/appname/app/controllers/users/confirmations_controller.rb

错误似乎来自Devise自动生成的文件,但我无法弄清楚为什么它只在生产模式下发生。

1 个答案:

答案 0 :(得分:1)

我认为您尝试使用rails generate devise:controllers覆盖设计默认行为,但您可能已经严重更改了它们。

请确保:

  1. 您需要覆盖默认控制器,除非您可以删除controllers/users文件夹(如果您应用的模型名称是Users
  2. 检查controller/users中所有文件的语法。