Displaying 2 results from an estimated 2 matches for "specialdescription".
2006 Jul 11
7
Rails associations: Easy Question requires dumb answer
...ve two Models:
class Template < ActiveRecord::Base
end
which has this migration:
/snip
t.column :name, :string
And the other model:
class Product < ActiveRecord::Base
has_one :template
end
with the migration:
/snip
t.column :qty, :integer, :default => 0
t.column :specialDescription, :string
t.column :template_id, :integer
Finally here is my controller code:
/snip
t=Product.create(:specialDescription=>"Cleans shit",:qty=>12)
t.template=Template.find(:first)
t.save
My intention is to have several Products reference one template. But
when I execute th...
2006 Jul 13
8
can''t convert true into integer
I have a method:
? def reduceProuctInventoryBy(product_id, reduction)
? ? t=Product.find(:first, :conditions =>["id = ?", product_id])
? ? t.qty=(t.qty-reduction)
? ? t.save
? end
and the model:
class Product < ActiveRecord::Base
? validates_presence_of :qty, :specialDescription
? validates_numericality_of :qty
end
but when i run my method, I get this:
"can''t convert true into Integer"
and rails does not give me a line number in the trace the error back to,
any ideas?
ps
I am positive that Product.find(:first, :conditions =>["id = ?",...