Displaying 4 results from an estimated 4 matches for "contact_address".
2006 May 06
3
Question about one-to-many-to-many
...tables/models. I can''t get
cascading deletes (haven''t tried updates yet) to work when the master
record is deleted. I''m using MySQL 4.1.x, and the error message is:
Mysql::Error: #23000Cannot delete or update a parent row: a foreign key
constraint fails: DELETE FROM contact_addresses WHERE (contact_id = 1).
Is this something that''s not supported by MySQL? Or might I have setup
my models (has_many, belongs_to, etc.) incorrectly?
--
Posted via http://www.ruby-forum.com/.
2007 Aug 03
0
acts_as_paranoid and Association Extensions (has_one troubles)
...on_OBJECT.with_deleted. Has_many does like expected:
Model.association_COLLECTION.with_deleted.
* Example:
The disability of my approach you see below after the lines with
########### signs..
First on to: class Organization
class Organization < ActiveRecord::Base
acts_as_paranoid
has_one :contact_address, :as => :addressable, :dependent
=> :destroy do
def with_deleted
ContactAddress.with_scope(:find => {:conditions =>
"addressable_id = #{proxy_owner.id}"}) do
find_with_deleted(:all)
end
end
end
Loading development environment.
>> sc = SportCl...
2006 Aug 11
5
Unit tests - NilClass problem
...fixtures :customers
# Replace this with your real tests.
def test_create
test_creation_of :model => Customer,
:record => @customer,
:fixture => @first,
:attributes => [:id, :name, :contact_firstname,
:contact_lastname, :contact_address, :contact_country, :contact_state,
:contact_email, :contact_phone, :activationcode]
end
end
and when trying to run it I get:
------------
Loaded suite customer_test
Started
F
Finished in 0.731 seconds.
1) Failure:
test_create(CustomerTest)
[./../test_helper.rb:31:in `test_creation_of...
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...