Hi guys I'm tring to create a scope which find out all contacts with 0 address. Got error message ArgumentError: tried to create Proc object without a block
when running command 'Contact.noaddress' in rails c.
here's my contact model including scope
class Contact < ActiveRecord::Base
attr_accessible :email, :firstname, :lastname, :mobilephone, :fullname
has_many :addresses
validates_presence_of :firstname, :lastname
scope :noaddressed, lambda do |addresses|
joins(:addresses).where('addresses.created_at.empty?', true)
end
end
and here's address model
class Address < ActiveRecord::Base
attr_accessible :city, :country, :postalcode, :region, :street
belongs_to :contact
end
Could somebody help me please? Thanks a lot.