Displaying 1 result from an estimated 1 matches for "cartitemopt".
2006 Feb 27
1
Nested hash from form params into create()?
...d"=>"97"},
"5"=>{"option_id"=>"47"}}
}
## CONTROLLER ##
def add_to_cart
CartItem.create(params}
end
## MODELS ##
class CartItem < ActiveRecord::Base
belongs_to :variation
has_many :cart_item_options
end
class CartItemOption < ActiveRecord::Base
belongs_to :cart_item
end
## TABLES ##
CREATE TABLE cart_items (
id SERIAL,
variation_id INTEGER UNSIGNED NOT NULL
);
CREATE TABLE cart_item_options (
id SERIAL,
cart_item_id INTEGER UNSIGNED NOT NULL,
optional_id INTEGER UNSIGNED NOT NULL
);
## ERROR ##...