19 Jul 22:18
Undefined Method Errors
From: nick.bell71@... <nick.bell71@...>
Subject: Undefined Method Errors
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-07-19 20:19:37 GMT
Subject: Undefined Method Errors
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-07-19 20:19:37 GMT
Hi
I'm relative new to RoR - but I'm having a problem with some model
relationships that I thought should have worked. Hope someone can
help.
The code...
MODELS:
class Delivery < ActiveRecord::Base
belongs_to :vehicle
end
class Vehicle < ActiveRecord::Base
has_many :deliveries
def self.find_all_active
Vehicle.find(:all, :order => 'name', :conditions => ['is_active
= ?', true])
end
end
CONTROLLER:
@vehicles = Vehicle.find_all_active
VIEW:
<%= vehicle.deliveries.length %>
(Continue reading)
RSS Feed