Displaying 2 results from an estimated 2 matches for "create_contact".
2009 May 25
4
after_create and has_one association bug?
...ontact after I create an account
(via after_create). I''m not passing in a "name" field which the contact
requires via validates_presence_of, so the contact should not get saved,
but it in fact does.
class Account < ActiveRecord::Base
has_one :contact
def after_create
create_contact
end
end
class Contact < ActiveRecord::Base
belongs_to :account
validates_presence_of :name
end
The test...
class AccountTest < ActiveSupport::TestCase
test "this ain''t right" do
a = Account.create
p a.contact
p a.new_record?
end
end
produces...
#&...
2010 Jun 08
9
[Rails Heroku] Problem with saving object (on heroku hosting)
Hi All,
I have some strange problem which appears only on heroku hosting 2.3.5
default stack (not on my local computer)
I have some models. Here they are:
class Contact < ActiveRecord::Base
belongs_to :user
belongs_to :type, :class_name => "ContactType", :foreign_key =>
"type_id"
validates_presence_of :name, :on => :create, :message =>