Displaying 17 results from an estimated 17 matches for "order_items".
2006 Apr 14
3
Updateform with a has_many relationship ?
Hello all,
I would like to be able to update the "amount" of a certain item in
me order list.
The problem I run into is how to define the text_field element.
@order is the current order, which has_many :order_item which in turn
belongs_to :order.
order_item has a field "amount" which should be modified...
What I tried is this below, but I get a undefined method
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...
2006 Dec 02
0
Fwd: Re: Mocha and ActiveRecord
...>>
>> 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 = mock("order item", :do_something => nil)
>> order_items.push(item)
>> }
>>
>> order = Order.new(:order_items => order_items)
>> order.do_something
>> end
>>
>&g...
2007 Oct 13
4
Chapter 9
...veRecord::Base
include ActiveMerchant::Billing
before_validation :set_status
attr_protected :id, :customer_ip, :status, :error_message, :updated_at, :created_at
attr_accessor :card_type, :card_number, :card_expiration_month, :card_expiration_year, :card_verification_value
validates_size_of :order_items, :minimum => 1
validates_length_of :ship_to_first_name, :in => 2..255
validates_length_of :ship_to_last_name, :in => 2..255
validates_length_of :ship_to_address, :in => 2..255
validates_length_of :ship_to_city, :in => 2..255
validates_length_of :ship_to_postal_code, :in =&g...
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/.
2006 Jul 06
7
form_remote_tag submitting to an rjs file.
I have the following form that I am trying to use, but for some reason,
the form gets submitted with out the params values.
<%= form_remote_tag(:url => { :action => :add_item_to_order }) %>
<tr>
<td>
<%=collection_select(:order_item , :item_category_id,
@item_categories, :id, :name)%>
</td>
<td>
<%= text_field
2006 Jul 11
0
using acts_as_list storing the information in a session
Hi,
I have an order model that i am storing in a session, that is not
currently in the database. I am updating the page using ajax, and I do
not want to store the order in the database untill it is completely
filled out.
I have order_items that I am adding to the order, and I have used the
acts_as_list within the order_item model.
My problem comes when i try and rearrange the order_items using the
following code:
def move_item_up
@order = find_order
@order.order_items[params[:id].to_i].move_higher
@order.reload...
2006 Feb 20
0
YAML and has many associations
Hi,
I have the following:
order = YAML::load(order_yaml)
The YAML contains order_items too, and my order model has a has_many to
order_items.
When I do order.order_items, I don''t want Rails to go the db to get the
order_items, but use the order_items already contained in the object
created from the YAML.
How would I do this?
Thanks
Joerg
--
Posted via http://www.rub...
2006 Mar 09
1
[TIP] Making an intelligent form fields
After searching arround I found a quite smart solution to me for binding
form fields to model in an active way. I use aggregations with single
value objects such as
class Percentage
attr_accessor :value
def initialize(value)
@value = (value.is_a? String) ? value.tr('' %'', '''').to_f : value
end
def to_s
return unless value
2005 Dec 30
2
newbie
Hello There
I new to rails development and looking to write a simple site using
rails. Does any one know of and example ecommerce application that that
I can use as a base to build from. My db schema is very
simple--product, categories, orders and order_item tables. Any
suggestions will be highly appreciate.
Thanks
Pat
2006 Apr 20
2
Additional Fields in a Join Table
...the item
information for the specific order without changing it in the items
table (ie. the items table holds the default values for the item, and
the orders_items table holds the updated values, such as price, and
description)
Is it possible to leave the field names the same between both the
order_items table and the items table (both would have a price field).
I have been reading that there are problems when accessing these fields?
Is this the proper way of doing this?
Thanks,
Ryan Lundie
--
Posted via http://www.ruby-forum.com/.
2006 May 28
0
expanding details examples?
...store a value on the page and toggle it each time
it''s clicked - but it seems like there must be a better solution.
Here''s my makeshift .rjs template:
page.replace_html "items" + params[:id].to_s, :partial =>
''order_item'', :collection => @order_items
page.replace_html "item_footer" + params[:id].to_s, :partial =>
''order_item_form''
page.replace_html "comments" + params[:id], :partial =>
''order_detail'', :collection => @order_details
page.replace_html "comment_foot...
2006 Sep 08
1
testing question
...a customer model
function that returns what level of customer they are.. this is based
on what things they''ve ordered in the past. so my question: is it ok to
bring in other models when doing unit tests? i figure i will have to
load at least 3 other test fixtures to test this out (orders,
order_items, and inventory), but not even sure if i can actually use
the other models in the customer unit test because i tried putting test
= Order.new in my test and it failed on that line.. i''m starting to
think that maybe this aspect shouldn''t be tested in the unit test?
thanks in advanc...
2006 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
...ith 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 = OrderItem.new(:order_id => 1)
assert( orderitem.save, orderitem.errors.full_messages.join(''\n''))
end
end
The fixture:
first:
id: 1
sid: ''ON001''
All of the code can be found at htt...
2006 Jul 23
7
"throwing out the old": does Rails really not support...
Frankly I''m losing tolerance for the MS "stack." And I''m intrigued by
Rails. But in my outfit I''m not only the web person, but also the
application person and the DBA. So when I read that Rails doesn''t want
to handle things like "compound keys" I blew right by those claims,
thinking, "no way."
But before I go deeper, I
2009 Mar 31
3
serving xml
Hi All,
I''m trying to serve some XML from my Rails 2.0 server.
I have a Flash file that always reads its configuration from
/home/gallery.xml
So, I would like to build the contents from the database and serve it
back to the flash file when it hits my xml url.
If it was HTML that it was asking for then in my home controller I have
a gallery method that serves back a gallery.html.erb
2007 Feb 26
24
Ruby/rails port of Cocoon/hibernate
Hi,
I''m currently running an apache/jboss cocoon/flow/hibernate/ajax
paypal (directpayment) project and am looking into the possibility of
porting it across to ruby/rails. For that reason I would like to know
the following:
1. Can I call my java classes or would I be looking at a complete
rewrite in ruby?
2. How effective is ruby in terms of seperation of concerns regarding
design from