Displaying 11 results from an estimated 11 matches for "shipping_address".
2009 Jun 24
1
accepts_nested_attributes_for :reject_if issue
I have the following models:
class Order < ActiveRecord::Base
belongs_to :billing_address
belongs_to :shipping_address
accepts_nested_attributes_for :billing_address
accepts_nested_attributes_for :shipping_address, :reject_if => proc {
|attributes| attributes[''has_shipping_address''] != ''1'' }
def after_initialize
self.build_billing_address unless billing_address...
2007 Nov 20
2
confirming that a model instance was correctly created from POST params
...9;m wasting my time trying to verify that an addition I''ve made to legacy code is in fact setting a new attribute on a model.
Substruct''s (http://dev.subimage.com/projects/substruct) OrderHelper contains this method:
1 def create_order_from_post
2 @use_separate_shipping_address = params[:use_separate_shipping_address]
3
4 @order_user = OrderUser.find_or_create_by_email_address(
5 params[:order_user][:email_address]
6 )
7 @order_user.valid?
8
9 @order = Order.new(params[:order])
10 @order.valid?...
2006 Jun 01
4
how can I control when to commit a transaction?
hello
it seems like this question has appeared a few times with no answer:
how do you get rails to issue ''write'' statements (ie ''CREATE/UPDATE'') to
the database without committing each time?
I tried setting
ActiveRecord::Base.connection.begin_db_transaction
before calling any action on my object, but as soon as
myObject.save
or
myObject.update
is called,
2006 Apr 04
4
Aggregating two objects of the same type
I would like to have a customer that has references to two addresses,
a billing address and a shipping address. In a non-rails environment
I would have two keys in the customers table, billing_address_id and
shipping_address_id to reference the addresses. It appears that
ActiveRecord expects the parent id to reside in the child table,
regardless of whether the relationship is one-to-one or one-to-many.
What would the best approach be to persist this type of data
structure? I would prefer to avoid a one-to-many rela...
2009 Feb 26
1
composed_of, aggregate object isn't saved
I am relatively new to rails and I cannot figure out what is going on
here. I am using the composed_of method in an ActiveRecord class to
create two aggregate properties: shipping_address and billing_address.
The object properties are getting populated from the form and validation
is working - no problem. When I call order.save, though, everything is
being saved except the address fields. I am not getting any errors - it
is just that none of the address info is saved to the database...
2006 Jun 06
1
Please Help with single table inheritance relationships
...to :person
end
class BillingAddress < Address
belongs_to :person
end
class ShipFromAddress < Address
belongs_to :retailer
def retailer_id= (input)
person_id = input;
end
def retailer_id
person_id
end
end
# Made these changes:
class Person < ActiveRecord::Base
has_one :shipping_address
has_one :billing_address
end
class Retailer < ActiveRecord::Base
has_one :ship_from_address
end
---
Now, this all makes some sense to me, but I don''t know that it makes
Rails sense (and there is no validator or Relationship Manager to tell
me if it is valid syntax or set of comma...
2006 Apr 08
2
one-to-one relationship confusion
...objects in a similar way, so I would really like to avoid putting the
keys referencing the customer or other objects in the addresses table.
Addresses are exclusively referenced by parent objects and a
many-to-many association is not appropriate.
Ideally I would like the customers table to use a shipping_address_id
and a billing_address_id to reference the aggregate addresses. For
illustration purposes, another object, company might have a
main_address_id, an after_hours_address_id and a weekend_address_id.
In order to keep the keys in the customer table the belongs_to
statements are in the customer mode...
2006 Mar 24
0
A "virtual model" that encapsulates other models?
...ta together
from tables used by other models?
For instance, let''s say I have a model of a "customer" which has_many
"addresses", of which one of the "addresses" is the default address.
So what I''d like to do is to actually have a model, say
"Shipping_Addresses" that pulls "First name" and "Last name" out from
"customer" and sticks it to the rest of the address details as pulled
from "addresses".
Is this doable?
--
Posted via http://www.ruby-forum.com/.
2005 Sep 29
0
Table relationships with single table inheritance
...and "BillingAddress" as
subclasses. It looks like this:
class Address < ActiveRecord::Base
End
class ShippingAddress < Address
has_one :order
End
Class BillingAddress < Address
End
On the Order side:
class order < ActiveRecord::Base
belongs_to :ShippingAddress??? Or shipping_address??
End
SB
2006 Jul 21
3
How can I create OrderItems that go in a Order?
I suspect my problem is 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, an...
2006 May 04
22
Should controllers be "smart"?
I''m working on a small project with a friend, and one of the things we
needed to do was send off an email whenever someone signs up an
account. His implementation was pretty simple - throw a
deliver_welcome call inside the controller after the signup. I''m sure
that this is a pretty common thing to do.
The problem, in my mind, was that the app now became tied to two
places -