LoginSignup
5
4

More than 5 years have passed since last update.

Rails4.2 アップグレード時のエラーなどのメモ

Last updated at Posted at 2014-12-21
  • PostgreSQL 9.4.0
  • ruby 2.1.3

発生ごとに追記予定。

PG::ProtocolViolation: ERROR: bind message supplies 0 parameters, but prepared statement "" requires 1

参考コード

scope :with_closed_business_days, ->(account) do
      business_days = BusinessDay.where(account_id: account.id).closed_week.arel.as('business_days')

      select(calendars[Arel.star])
      .joins(calendars.join(business_days)
        .on(calendars[:wday].eq(business_days[:wday])).join_sources)
    end

scopeの引数がSQLにbind?されないエラー。
以前は

business_days = BusinessDay.where(account_id: account.id).closed_week.arel.as('business_days')の箇所を、business_days = account.closed_week.arel.as('business_days')としていた場合に出ていた気がする。

なのでwhereの箇所を変更するといけた。

   scope :with_closed_business_days, ->(account) do
      business_days = BusinessDay.closed_week.arel.as('business_days')

      select(calendars[Arel.star])
      .where(business_days[:account_id].eq(account.id))
      .joins(calendars.join(business_days)
        .on(calendars[:wday].eq(business_days[:wday])).join_sources)
    end

のですが!、これだと、left outer joinのarelテーブルでは解決できないのでした。そこで色々と試しましたところ。

whereの箇所をarel_tableで記述するといけました。arel_table使うときはすべてarel_tableで書くのか?

scope :with_closed_business_days, ->(account) do
      business_days = BusinessDay.arel_table
      business_days = BusinessDay
        .where(business_days[:account_id].eq(account.id)).closed_week.arel.as('business_days')

      select(calendars[Arel.star])
      .joins(calendars.join(business_days)
        .on(calendars[:wday].eq(business_days[:wday])).join_sources)
    end

slim-railsのバージョン依存がずれる

gem 'slim-rails', github: 'ericboehs/slim-rails'
上記で一時的に管理

config/application.rb

追記
config.active_record.raise_in_transactional_callbacks = true

ActiveJob

Mailerのdeliverメソッドをdeliver_nowに変更。
job管理はqueを使っているが、ActiveJobとの絡みは別途

これでテストは通ったのでゆっくり新機能をみてみます。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4