Paginate with two tables?

First I read previous thread with similar problem but I don’t find
(problem is little diffrent)
Hello, I have problem with display information from two tables using

Here is code.


create table subscribers (
id integer not null auto_increment,
name varchar(32) not null,
surname varchar(64) not null,
create_timestamp DATETIME not null,
modify_timestamp DATETIME not null,
primary key (id));

create table contracts (
id integer auto_increment,
subscriber_id integer,
service_id integer,
sign_date timestamp,
representative varchar(128) not null,
constraint fk_subscriber foreign key(subscriber_id) references
primary key(id));

There is something like this in controller:
@subscriber_pages, @subscribers = paginate :subscriber, :per_page =>
10 ,
:order => ‘create_timestamp DESC’, :include => :contract

But I’m getting error:

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.


20: <% for contract in subscriber.contract %>
21: #<%= link_to show_service(contract.service_id), { :controller =>
‘contracts’,:action => ‘show’, :id => } %>
The error occured while evaluating nil.each

Of course there is above line 18 something like <% for subscriber in

But …:
vader:/srv/www/rails/rmgr # ./script/console
Loading development environment.

@subscriber = Subscriber::find 37
=> #<Subscriber:0x40ab547c @attributes= …[cut]

=> [#<Contract:0x40aac750 @attributes={“service_id”=>“1”, “id”=>“3”,
“representative”=>“2”, “subscriber_id”=>“37”, “sign_date”=>“2006-01-09

Why this isn’t working with paginate ??

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs