Displaying 4 results from an estimated 4 matches for "orderaddress".
2007 Dec 05
9
Does mock_model''s :null_object option work?
...on''t have the time to refactor nicely right now. I''m just trying to get past the untested/un-speced cruft quickly to write the spec for my new code, so I''m looking for expediency over prettiness.
I''m specifying
before( :each ) do
@order_address = mock_model( OrderAddress, :null_object => TRUE )
end
but finding that unstubbed/unmocked method calls on @order_address still throw error messages like:
Mock ''OrderAddress_1026'' received unexpected message :first_name with (no args)
so I''m starting to wonder whether the :null_object option...
2007 Nov 20
2
confirming that a model instance was correctly created from POST params
...@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(params[:billing_address])
20 @shipping_address = OrderAddress.new(params[:shipping_address])
21 end
22 @billing_address.valid?
23
24 if @use_separate_shipping_address
25 @shipping_address.valid?
26 end
27
28 @ord...
2009 Jun 24
1
accepts_nested_attributes_for :reject_if issue
..._address, :reject_if => proc {
|attributes| attributes[''has_shipping_address''] != ''1'' }
def after_initialize
self.build_billing_address unless billing_address
self.build_shipping_address unless shipping_address
end
end
class ShippingAddress < OrderAddress
attr_accessor :has_shipping_address
end
class OrderAddress < ActiveRecord::Base
validates_presence_of :name
#more validations here..
end
And the view:
<% form_for @order do |f| %>
#...
<% f.fields_for :shipping_address do |addr_f| %>
<%= addr_f.check_box :has_ship...
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,