Displaying 20 results from an estimated 48 matches for "order_id".
2007 Apr 11
12
redirection doesn''t get detected well?
I''m doing a redirect in one of my controller actions and somehow I can''t
spec it, see this pastie: http://pastie.caboo.se/53120.
When following the link from a browser I''m being redirected to the right
page.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
I seem to be missing something trying to use ''validates_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...
2006 Dec 07
2
Problem saving parent and children using belongs_to, class_name, and foreign_key
...Save everything
I''m using Rails Edge.
----
class PayjunctionOrder < ActiveRecord::Base
has_many :line_items
end
------------------
----
class LineItem < ActiveRecord::Base
belongs_to :order,
:class_name => "PayjunctionOrder",
:foreign_key => "order_id"
...
------------------
----
class StoreController < ApplicationController
def checkout_complete
...
@order = PayjunctionOrder.new
@order.line_items << LineItem.new(:product => product, :quantity =>
qty, :total_price => product.price * qty)
@order.save!
...
--...
2006 Jan 12
5
Question about using DISTINCT in ActiveRecord find method.
Hi,
Am relatively new to the RoR world. My question is quite simple.
I have a query like such:
shipmentNumbers = Order.find_by_sql(["select distinct s.id from orders
o, line_items li, shipment_lines sl, shipments s where o.number=? and
o.id = li.order_id and li.id = sl.line_item_id and sl.shipment_id =
s.id", number])
The above query works fine. I wanted to do the same query using the
query below:
shipmentNumbers = Order.find(:all,
:conditions => ["number = ?", number],
:joins => "as o join line_items as li o...
2006 Mar 31
2
Model inheritance is borken in Rails1.1
...yment
end
class CAD < OrderPayment
end
and following is error i''m getting with rails1.1.0 above code is working
fine with rails1.0.0
NameError in Order#add_payment
uninitialized constant LC
RAILS_ROOT: script/../config/..
Application Trace
<http://0.0.0.0:3000/order/add_payment?order_id=44#> | Framework
Trace <http://0.0.0.0:3000/order/add_payment?order_id=44#> | Full
Trace<http://0.0.0.0:3000/order/add_payment?order_id=44#>
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:112:in
`const_missing''
/usr/lib/ruby/gems/1.8/gems...
2007 Sep 05
8
Hi..Guys new plugin again
...s table to an id column in a customers table, the plugin
creates:
Order.belongs_to :customerCustomer.has_many :orders
If there is a uniqueness constraint-eg unique index-on a foreign-key
column, then the plugin will creates a has_one instead of a has_many.
For example, given a foreign-key from an order_id column with a
uniqueness constraint in an invoices table to an id column in an
orders table, the plugin creates:
Invoice.belongs_to :orderOrder.has_one :invoice
Additionally, if there is a position column in the child table, the
parent association will be created with an order clause.
For example...
2012 Jan 26
1
adding additional information to histogram
Hi,
I am a beginner with R, and I think the answer to my question will
seem obvious, but after searching and trying without success I've
decided to post to the list.
I am working with data loaded from a csv filewith these fields:
order_id, item_value
As an order can have multiple items, an order_id may be present
multiple times in the CSV.
I managed to compute the total value and the number of items for each order:
oli <- read.csv("/tmp/order_line_items_data.csv", header=TRUE)
orders_values <- tapply(oli[[2]],...
2006 Jun 20
1
ActiveRecord saving madness?
Hello,
First of all, I love RoR. I am studying it, and I am finally "getting
there".
However, I do have a bit of a problem with ActiveRecord''s saving
behaviour.
Imagine to have Orders (id, name) {has_one:invoice} and Invoices (id,
order_id) {belongs_to :order} .
If you type:
invoice = Invoice.new(...whatever...)
an_order.invoice = invoice
if invoice fails to save, you will never know. What''s worse, an_order
will be saved, and will have a nasty nil, which means that your rhtml
template will *fail* when going through that...
2007 Nov 20
2
confirming that a model instance was correctly created from POST params
...@order.order_number = Order.generate_order_number
36 @order.save!
37 end
38 OrderAddress.transaction do
39 # Addresses
40 @billing_address = @order_user.order_addresses.create(params[:billing_address])
41 @billing_address.order_id = @order.id
42 @billing_address.is_shipping = true
43 @billing_address.save!
44 if @use_separate_shipping_address then
45 @shipping_address = @order_user.order_addresses.create(params[:shipping_address])
46 @shipping_address.is_sh...
2006 Jan 06
6
HABTM problem not saving all associations
...9;, '''',
'''', '''', NULL, 1, '''', '''', '''', '''', NULL)
loan_types_orders Columns (0.001317) SHOW FIELDS FROM loan_types_orders
SQL (0.000496) INSERT INTO loan_types_orders (`order_id`,
`loan_type_id`) VALUES (5, 1)
loan_types_orders Columns (0.001122) SHOW FIELDS FROM loan_types_orders
SQL (0.000471) INSERT INTO loan_types_orders (`order_id`,
`loan_type_id`) VALUES (5, 2)
loan_types_orders Columns (0.001477) SHOW FIELDS FROM loan_types_orders
SQL (0.000456) INSE...
2013 Feb 18
6
How to clear ActiveRecord query cache on associations with dynamic table
...them:
Order.table_name=''v1_orders''
OrderLine.table_name=''v1_order_lines''
Query:
OrderLine.joins(:order).where(Order.table_name=>{:customer_id=>1}).all
Result: Select v1_order_lines.* FROM v1_order_lines INNER JOIN v1_orders ON
v1_orders.id=v1_order_lines.order_id WHERE v1_orders.customer_id=1
So far so good
Now we alter the table names:
Order.table_name=''v2_orders''
OrderLine.table_name=''v2_order_lines''
and requery:
Query:
OrderLine.joins(:order).where(Order.table_name=>{:customer_id=>1}).all
Result: Select v2_o...
2006 Feb 16
9
association not inserted automatically.
...@ord = Order.new(params[:ord])
@ord.line_item = LineItem.new(params[:lineitem])
if @ord.save
redirect_to :action => ''list''
else
render :action => ''new''
end
end
and that is giving an exception saying foreign key constraint fails on
line_item because the order_id is 0 and more over the order is not saved
!
any help ?
--
Posted via http://www.ruby-forum.com/.
2005 Dec 21
3
Lazy Loading?
I''m having problems with what seems to be lazy loading behavior in Ruby
on Rails. I have two objects in a parent-child relationship such as:
class Order < ActiveRecord::Base
has_many :items, :dependent => true
end
class Item < ActiveRecord::Base
belongs_to :order
end
I put an instance of the Order object into the session using:
session[:order] = Order.new
2006 Mar 21
11
Stuck on ActiveRecord
Hi,
I''m having great fun developing with Rails but I''ve come to a problem
that I can''t quite figure out.
I have an Order object that "has_many" order_lines. This works perfectly
and I can see all the lines.
The OrderLine object has an order_id field as well as product_id and
amount.
Now ideally I would want to do :
order.orderline[0].product.name
for example to pull back the name of the product it''s linking to - but
no matter what I try, I cannot get that to work.
Can anyone tell what I''m doing wrong? I imagine it&...
2008 Apr 25
5
Best way to pass ID variable to partials - global var??
I have several orders that are being updated in an internal data entry
app. I start by going from an order to pop-up form that allows a user
to select items to add to a field in the order. The pop-up form
contains 2 partials for drag and drop functionality from AWD. The user
starts by selecting a category in a drop down list. Then on select, the
first partial is filled with the list of
2006 Feb 24
7
One To Many To Many
Hey all,
I''m trying to find a simple way to reference all of the objects that
belong to their parent''s parent. In other words:
Clients --> Orders --> LineItems
How do I get all of a client''s lineitems in one array (i.e.,
client.all_lineitems)?
Thanks!
-Neal
--
Posted via http://www.ruby-forum.com/.
2013 May 14
5
Why joins queries make result readonly?
...by_executor, ->(executor_id) {
joins(:executors).where(specialists: {id: executor_id} ) }
end
and make query Order.by_executor(1) so that I get:
Order Load (2.0ms) SELECT "orders".* FROM "orders" INNER JOIN
"order_executors" ON "order_executors"."order_id" = "orders"."id" INNER
JOIN "specialists" ON "specialists"."id" =
"order_executors"."specialist_id" WHERE "specialists"."id" = 1
=> [#<Order id: 20, orderable_id: 11, orderable_type: "PlanDev...
2006 Jul 29
0
SOAP for large datasets
...descript => items.descript, :amount => items.amount,
:quan
t => items.quant, :trans_id => items.trans_id, :trans_date =>
items.trans_date)
end
trans = []
for history in order.histories
trans << TransactionData.new(:sale_type => history.sale_type,
:order_id => order.order_id, :trans_id => history.trans_id, :outcome
=>
history.outcome)
end
ar << CustomerData.new(:orderitem_data => oi, :transaction_data
=> trans, :address => order.address, :address2 => order.address2,
:f_na
me1 => order.f_name1, :l_name1 =>...
2006 Jun 13
2
Query for multiple tables with find question :)
Hello all,
I am trying to figure out how to do this with find instead of doing it
via find_by_sql
For example I am trying to list all my completed orders, however I need
to check the progresses table to make sure the "currentlevel" in the
progress table equals
"endlevel" in the orders table.
The sql below works fine, but I am just curious how to do it another
way.
def
2006 Mar 01
2
active_record postgresql adapter problem
...o only support database types that active_record knows about?
RuntimeError: ERROR C42804 Mcolumn "unit_price" is of type money but
expression is of type numeric HYou will need to rewrite or cast the
expression. Fparse_target.c L361 RupdateTargetListEntry: INSERT INTO
line_items ("order_id", "product_id", "quantity", "unit_price")
VALUES(1, 3, 1.0, 5367829.95)
Regards,
Jim
--
Posted via http://www.ruby-forum.com/.