First I read previous thread with similar problem but I don''t find
answer
(problem is little diffrent)
Hello, I have problem with display information from two tables using
paginate..
Here is code.
##### SQL
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
subscribers(id),
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.
18: <td>
19:
20: <% for contract in subscriber.contract %>
21: #<%= link_to show_service(contract.service_id), { :controller =>
''contracts'',:action => ''show'', :id =>
contract.id } %></br>
The error occured while evaluating nil.each
Of course there is above line 18 something like <% for subscriber in
@subscribers ...
But ...:
vader:/srv/www/rails/rmgr # ./script/console
Loading development environment.>> @subscriber = Subscriber::find 37
=> #<Subscriber:0x40ab547c @attributes= ..[cut]>> @subscriber.contract
=> [#<Contract:0x40aac750
@attributes={"service_id"=>"1",
"id"=>"3",
"representative"=>"2",
"subscriber_id"=>"37",
"sign_date"=>"2006-01-09
14:10:57"}>]>>
Why this isn''t working with paginate ??
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060110/10516b58/attachment.html