- 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との絡みは別途
これでテストは通ったのでゆっくり新機能をみてみます。