Displaying 11 results from an estimated 11 matches for "orderitem".
2008 Jun 04
2
Mock with an attributes that has state
I''m developing a rails application. I have an Order model that has_many
OrderItems.
I mocked the OrderItem model in my Order specs using mock_model. I thought
I should focus my specs on each model and always mock associated models.
In my Order model I need a way to merge OrderItems which have the same cost
and same product_id. That I can spec.
The other thing this merge hel...
2006 Jul 21
3
How can I create OrderItems that go in a Order?
...s similar to having an order and wanting to have
order items as part of the order, so I''ll explain the problem in those
more familiar terms and then explain what if anything makes my actual
situation different at the end.
In an Order lets say you have: shipping_address and a shipped bool.
OrderItem has quantity and name
So Order has_many :OrderItems, and OrderItem belongs_to :Order
It''s pretty easy to make it so you can create an Order then go to
another URL and create a OrderItem and associate (say with a select)
the Order the OrderItem belongs to, and so on.
What I really want t...
2006 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
...inclusion_of'' to
validate a foreign key and was hoping some one could piont out my
mistake?
The problem seems to be that Order.find_all.collect is not returning an
array that contains the order_id, if I replace it with a hardcoded array
everything works as expected.
The model:
class OrderItem < ActiveRecord::Base
validates_inclusion_of :order_id, :in => Order.find_all.collect {
|order| order.id }
belongs_to :order
end
The test:
class OrderItemTest < Test::Unit::TestCase
fixtures :orders, :order_items
def test_validates_inclusion_of_order_id_in_orders
orderitem =...
2005 Dec 25
2
[repost] newbie questions
...ess = Address.new
end
end
I also created the following checkout.rhtml file:
<% @page_title = "Checkout" -%>
<%= error_messages_for(:order) %>
<%= start_form_tag(:action => "update_order") %>
<table>
<%= render(:partial => ''orderitem'', :collection => @items) %>
</table>
<%= submit_tag "Update" %>
<%= end_form_tag %>
Finally I created the following partial:
<% product = orderitem.product %>
<tr>
<td><%= check_box ''orderitem'', ''de...
2005 Apr 13
2
Creating multiple option groups
...ion_sets
end
class OptionSet < ActiveRecord::Base
has_many :item_options
belongs_to :item
end
# Has fields ''name'' and ''value''
class ItemOption < ActiveRecord::Base
belongs_to :option_set
end
When the user chooses an item and its options, it creates an OrderItem
object, which just contains the id of the item, the id of the order,
the quantity, and options. I can handle everything easily, except for
the options. I don''t know how to generate the select tags, and then
store the options with the OrderItem. Can anyone help me out?
Thanks, Pat
2006 Mar 13
8
Nested find(:all, :include => ) statements
Is there a way for me to do:
OrderItem.find(:all, :include => [:user, :product => [:supplier]]
So I don''t have a supplier_id on my order_item, but have it on my
product, which is part of order_item.
Joerg
--
Posted via http://www.ruby-forum.com/.
2005 Dec 23
0
newbie question
...ess = Address.new
end
end
I also created the following checkout.rhtml file:
<% @page_title = "Checkout" -%>
<%= error_messages_for(:order) %>
<%= start_form_tag(:action => "update_order") %>
<table>
<%= render(:partial => ''orderitem'', :collection => @items) %>
</table>
<%= submit_tag "Update" %>
<%= end_form_tag %>
Finally I created the following partial:
<% product = orderitem.product %>
<tr>
<td><%= check_box ''orderitem'', ''de...
2006 Jul 29
0
SOAP for large datasets
...ilitzation goes up to almost 70%.
A simpler application where I just use plain xml in the request and
response, and use a bit of to_xml and REXML for building the trees
still takes a good amount of memory but nowhere near the amount of
cpu.
The data is from 3 tables. Customers, transactions, and orderitems.
I created a struct for customers and in customers there are two
members that contain a struct for transactions and orderitems.
Right now the code looks like this. Any ideas on how to optimize it?
Or even ideas on better methods then using soap for something like
this?
@orders = Customer.find(:...
2006 Dec 02
0
Fwd: Re: Mocha and ActiveRecord
...er <jbrains762 at gmail.com>
Date: 02-Dec-2006 02:48
Subject: Re: Mocha and ActiveRecord
To: ruby-talk ML <ruby-talk at ruby-lang.org>
James Mead wrote:
> On 28/11/06, J. B. Rainsberger <jbrains762 at gmail.com> wrote:
>>
>> Suppose I have an Order, which has_many OrderItems. Suppose I want to
>> write a test that checks that when I ask the Order to do something, it
>> asks its order items to do that something. I tried to do this like so:
>>
>> def test_delegates
>> order_items = []
>> 3.times {
>> item = mo...
2006 Mar 14
5
GROUP BY and SUM
I have orders, order_items, and products.
I want to collate several orders so that I can get a SUM of quantities
ordered for each product etc.
Can I say something like (the below gives an error on :sum, and ignores
:group)
OrderItem.find(:all, :sum => ''quantity'', :group => ''product_id'',
:include => [:order, :product])
I want to get back a collection of order_items, GROUPed BY product_id.
It is important for me to get back order_items, as then I can get to the
product using the b...
2004 Nov 30
1
RE: question about rails regarding handling more than onetable in one view
...extensive explanation of how associations work in
Rails.
For your example:
class Provider > ActiveRecord::Base
has_and_belongs_to_many :depts
end
class Dept > ActiveRecord::Base
has_and_belongs_to_many :providers
end
class Order > ActiveRecord::Base
has_many :orderitems
end
class Orderitem > ActiveRecord::Base
belongs_to :order
end
HTH,
Jarkko
On 30.11.2004, at 18:16, ChongQing Xiao wrote:
Hi, Everyone
I am just starting to look at the rail and really like how it
works.
One question I can not figure out is how rails...