On Nov 27, 4:47 pm, Joe Smith <[EMAIL PROTECTED]>
wrote:
> class Shopping_cart < ActiveRecord::Base
>   belongs_to :owner,
>     :class_name => "user",
>     :foreign_key => "owner_id"
>
>   has_many :shopping_cart_items,
>     :class_name => "shopping_cart_item",
>     :finder_sql => "select ti.* from shopping_cart_items ti,
> shopping_carts t
>         where ti.owner_id = t.owner_id"
> end
> --

Your shopping_cart_item (singular) is probably a rails model and it
needs to start with a capital letter as it should be a ruby
constant.

When you define a model or any class in the normal way, you do
something like this
  class ShoppingCartItem <  ActiveRecord::Base
  ...
ShoppingCartItem is a ruby constant because it starts with capital (as
opposed to local variable or method name).
Also, you should probably use camel case instead of underscores for
constant names - that seems to be a convention but with rails it might
be a requirement (not completely sure as I've never done it that way).
You'd then refer to this class using class_name =>
'ShoppingCartItem'   .
Your underlying table can stay as shopping_cart_items, of course.

You could probably dispense with class_name altogether if
"has_many :shopping_cart_items" refers to model ShoppingCartItem.
Rails will infer that for you.

--
Daniel Bush
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to