小编Dan*_*Dan的帖子

使用带有Rails/Spork/RSpec的database_cleaner时的SQLite3 :: SQLException

当试图在database_cleaner的GitHub页面上关注示例时,我从RSpec遇到以下错误:

 ActiveRecord::StatementInvalid:
   SQLite3::SQLException: cannot start a transaction within a transaction: begin transaction
Run Code Online (Sandbox Code Playgroud)

spec_helper.rb中使用的配置是:

require 'spork'
require 'database_cleaner'

Spork.prefork do
 # .. snip
  RSpec.configure do |config|
   # .. snip
    config.before(:suite) do
      DatabaseCleaner.strategy = :transaction
      DatabaseCleaner.clean_with(:truncation)
    end

    config.before(:each) do
      DatabaseCleaner.start
    end

    config.after(:each) do
      DatabaseCleaner.clean
    end
  end
end

Spork.each_run do

end
Run Code Online (Sandbox Code Playgroud)

sqlite rspec ruby-on-rails spork

7
推荐指数
2
解决办法
3235
查看次数

PHP-FPM具有专用的错误日志文件

我已经建立了一个Apache2/PHP-FPM站点,并希望将PHP-FPM的错误记录到自己的错误日志文件中.但是,使用当前配置,错误将以以下格式记录到/var/log/php5-fpm.log:

WARNING: [pool www] child 22926 said into stderr: "NOTICE: PHP message: PHP Parse error:  syntax error, unexpected 'if' (T_IF) in /var/www/site.com/error.php on line 1"
Run Code Online (Sandbox Code Playgroud)

在我的/etc/php5/fpm/pool.d/www.conf中,我有以下选择:

php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
catch_workers_output = yes
Run Code Online (Sandbox Code Playgroud)

禁用时catch_workers_output,错误日志记录将完全停止.但是,在phpinfo()输出中,它显示了我在配置中指定的日志文件.

为什么PHP5-FPM不尊重此日志文件.有没有办法让单独文件中记录的fpm池有错误?

我的php版本:

# php5-fpm  -v
PHP 5.4.9-4~precise+1 (fpm-fcgi) (built: Nov 30 2012 10:48:01)
Run Code Online (Sandbox Code Playgroud)

谢谢你的任何信息!

php logging

6
推荐指数
1
解决办法
2万
查看次数

通用功能允许任意键

为什么以下代码编译成功?由于bar不是其中的一部分MyState,我希望它会产生编译器错误.

type MyState = { foo: number; };
type Reducer<T> = (state: T) => T;

const wtf: Reducer<MyState> = (state) => {
  return { foo: 123, bar: 123 }; // `bar` isn't part of MyState
};
Run Code Online (Sandbox Code Playgroud)

typescript

4
推荐指数
1
解决办法
112
查看次数

猴子修补ActiveResource ::错误

我遇到了一个已经解决的 ActiveResource 问题,并试图将它修补到我的应用程序中而没有太多运气.

我在config/initializers /中添加了一个包含以下内容的文件:

class ActiveResource::Errors < ActiveModel::Errors
    # https://github.com/rails/rails/commit/b09b2a8401c18d1efff21b3919ac280470a6eb8b
    def from_hash(messages, save_cache = false)
      clear unless save_cache

      messages.each do |(key,errors)|
        errors.each do |error|
          if @base.attributes.keys.include?(key)
            add key, error
          elsif key == 'base'
            self[:base] << error
          else
            # reporting an error on an attribute not in attributes
            # format and add themActive  to base
            self[:base] << "#{key.humanize} #{error}"
          end
        end
      end
    end

    # Grabs errors from a json response.
    def from_json(json, save_cache = false)
      decoded = ActiveSupport::JSON.decode(json) …
Run Code Online (Sandbox Code Playgroud)

monkeypatching ruby-on-rails activeresource

1
推荐指数
1
解决办法
1352
查看次数