I''m studying rails
I am coding depot application in Agile web development with rails book
I have Cart model code like that :
class Cart
attr_reader :items
def initialize
@items = []
end
def add_product(product)
current_item = @items.find {|item| item.product == product}
if current_item
current_item.increment_quantity
else
@items << CartItem.new(product)
end
end
def total_price
@items.sum { |item| item.price }
end
end
above code is same with that of the book
but depot app have a error
Cart class doesn''t inherit from ActiveRecode::Base
But, Error message is like that
>> c = Cart.new
ActiveRecord::StatementInvalid: Mysql::Error: #42S02Table
''depots_development.carts'' doesn''t exist: SHOW FIELDS
FROM `carts`
plz, help me~
2008. 02. 25, 오후 6:28, Xavier Noria 작성:
>
> On Feb 25, 2008, at 7:28 , Ken Le wrote:
>
>> Is it possible to make a model that does not map to a database table?
>> If so how?
>
> A "model" is a class that represents something in the problem
domain,
> Rails does not assume it is persistent. Just define a class Foo in
> app/
> models/foo.rb without inheriting from AR::Base.
>
> -- fxn
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---