Displaying 13 results from an estimated 13 matches for "billing_address".
2008 Dec 02
4
Am I wrong or is fields_for not working right in Rails 2.2.2
...about what the fields_for method is supposed to
do, but for some reason I thought using it scoped an object around an
association.
For example, I have a User class and when you''re creating a new user I
want to use fields_for to add a BillingAddress to the user like so:
<%- fields_for :billing_address do |billing_address_form| -%>
<%= render :partial => ''billing_addresses/form'', :locals => { :f =>
billing_address_form } %>
<%- end -%>
This however, is not scoping the user object around the billing address
form fields because when I view source, I see...
2007 Nov 20
2
confirming that a model instance was correctly created from POST params
...5 params[:order_user][:email_address]
6 )
7 @order_user.valid?
8
9 @order = Order.new(params[:order])
10 @order.valid?
11
12 # Look up billing address and update if customer is logged in.
13 if @customer
14 @billing_address = @customer.billing_address
15 @billing_address.attributes = params[:billing_address]
16 @shipping_address = @customer.billing_address
17 @shipping_address.attributes = params[:shipping_address]
18 else
19 @billing_address = OrderAddress.new(para...
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,
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_add...
2008 Jul 07
0
ActiveRecord in Rails 2.1.0 misbehaving for Aggregate Attr.
...the partial_updates attribute for that model to false.
N
Specific use-case:
I have an Account model that shadows the accounts table in database.
This account object contains a composite object (amongst others) called
BillingAddress defined within the Account model class as follows:
composed_of :billing_address,
:mapping => [%w(address_1 address_1), %w(address_2 address_2),
%w(address_3 address_3),
%w(city city), %w(state state), %w(zip zip),
%w(card_country country)] do |params|
BillingAddress.new params
end
To test this theory, in the Rails Co...
2006 Jul 30
3
ActiveRecord - Multiple Address for a single record
...simple:
class Location < ActiveRecord::Base
has_one :address, :as => :addressable
end
What I''m having trouble with is the company model. I''ve currently got:
class Company < ActiveRecord::Base
has_one :main_address, :as => :addressable
has_one :billing_address, :as => :addressable
has_one :alternate_billing_address, :as => :addressable
has_many :locations
end
This is clearly not current, as each address record only has room to
point back to a single company record. This is a common problem, so I''m
sure a standard solu...
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 a...
2009 Mar 10
0
autosave no longer a valid option for belongs_to?
...t''s not in the ActiveRecord API doc
(ar.rubyonrails.org).
Does anyone have any more information on this? What is the current best
practice for persisting your child objects when saving a parent object?
Here''s an example:
class PaymentMethod < ActiveRecord::Base
belongs_to :billing_address, :class_name => "Address"
end
class Address < ActiveRecord::Base
validates_presence_of :line_one
end
class PaymentMethodsController < ActionController::Base
def update
@pm = PaymentMethod.find(params[:id])
@pm.billing_address.line_one = params[:billing_address][:line_...
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. I even
ran script/...
2006 Jun 06
1
Please Help with single table inheritance relationships
...Address < 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 commands), and it does not run:...
2006 Apr 08
2
one-to-one relationship confusion
...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 model and the has_one stateme...
2007 Nov 21
0
Testing transactional updates in story runner
How do you guys test transactional updates with story runner?
I have an action that needs to update four different models:
Enrollment.transaction do
@contact.update_addresses(params[:contact_address], params
[:billing_address])
@enrollment.update_attributes!(params[:enrollment])
end
The last update_attributes! will raise ActiveRecord::RecordNotValid
if anything was invalid (it cascades to contact and further to
addresses), and thus cause a rollback, so either all the updates go
through or none of them...
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 -