Hi all,
Solaris 10
Ruby 1.8.4
Rails 1.0.0
Postgres 8.1
postgres driver 0.7.1
I’m having a problem with getting paginate() to properly pick up an FK
constraint properly.
I don’t seem to have this issue with ActiveRecord, however. Consider:
create table start_dates (
id bigserial,
start_date date unique,
max_slots int default 40,
primary key (id)
);
create table schedules (
id bigserial,
start_date_id int,
…
foreign key (start_date_id) references start_dates (id),
primary key (id)
);
class StartDate < ActiveRecord::Base
has_many :schedules
end
class Schedule < ActiveRecord::Base
belongs_to :start_date
end
The ActiveRecord portion works as expected:
condition = “date_trunc(‘day’, start_date) between date(?) and date(?) -
1”
Schedule.find(
:all,
:include => ‘start_date’,
:conditions => [condition, first,last]
)
However, in schedules_controller.rb, this fails:
@schedule_pages, @schedules = paginate(
:schedules,
:include => [‘start_date’],
:conditions => [condition, first, last]
)
PGError: ERROR: column “start_date” does not exist
: SELECT COUNT(*) FROM schedules WHERE (date_trunc(‘day’, start_date)
between
date(‘2006-2-01’) and date(‘2006-3-01 - 1’) - 1)
What am I doing wrong here?
Thanks,
Dan