Displaying 20 results from an estimated 100 matches similar to: "ActiveRecord - Multiple Address for a single record"
2006 May 09
7
polymorphic relation question
I am trying to get polymorphic relations to work for my app. What I am
trying to do is explained by this picture
http://iroll.org/code/
I can''t figure out the code for in the controller to create a new
phone_number and assign it to a person. I have tried everything I can
think of.
A) do my models look correct?
B) what would the commands look like in the console or a controller
action
2006 Jan 06
6
HABTM problem not saving all associations
Hello all,
I have an Order object that has and belongs to many Products and has
and belongs to many Loan Types. This is so I can select multiples of
each in my order entry screen via checkbox groups.
I''m having some trouble with saving multiple HABTM associations for a
single model object; only the first HABTM association declared in the
model will save during the initial @order.save
2008 Dec 02
4
Am I wrong or is fields_for not working right in Rails 2.2.2
I may be totally wrong 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
2006 Jul 06
2
Not accepting nil values in fields when CREATING a record
Hello,
I have a question for you.
In my application, I want to make sure that the database doesn''t have
any NULLs in fields.
I can''t use validates_presence_of, because it will puke if there''s an
empty string ("")
So... is there an EASY way to check if a list of fields is null?
Right now, I''m doing:
def validate()
[...]
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_address
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
2007 Nov 20
2
confirming that a model instance was correctly created from POST params
I''m wondering whether I''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]
2007 Apr 22
0
rename error using rebuild_index in console after searching
Hi,
I use ruby console to experiment acts_as_ferret, but I ran into file
rename error when I try to rebuild index after doing a search.
is this normal? I am using Ferret 0.10.9 in windows XP.
Loading development environment.
>> Address.rebuild_index
=> {}
>> Address.find_by_contents(''US'')
=> #<ActsAsFerret::SearchResults:0x4f2ffcc @total_hits=2,
2006 Apr 08
2
one-to-one relationship confusion
Hello,
I posted a similar email, earlier in the week, but I still must not be
getting it.
I have a customer that aggregates two addresses; a shipping address
and a billing address. Addresses can also be referenced by other
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
2006 Aug 10
4
exporting vcards from rails
i''m doing a site for someone that has a form set up to collect contact
information from the user. i installed the vpim gem and was hoping to
give my client a way to download all of the contact''s information as a
vcard. using the examples, i was able to get it working in ruby, but i''m
not quite sure how to generate and download a vcard on the fly.
has anyone done
2006 Jun 06
1
Please Help with single table inheritance relationships
I''ve been searching the web, wikis, and more, and I haven''t turned up
examples of how to have multiple entities in a single-table inheritance
related to anything.
I have an addresses table, but multiple entities can have Addresses:
both Person (which has 2 addresses) and Retailer. I''ve been told that I
need to use single-table inheritance, and this was my attempt:
2006 Jul 31
3
Polymorphic associations and single table inheritance
Running into an interesting problem that at first glance appears to be a
bug in the AR association code. However, it''s explicitly coded this way
so I''m not so sure.
I have some code like this:
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
end
class Person < ActiveRecord::Base
has_many :addresses, :as => :addressable,
2006 Oct 11
1
Polymorphic Validations
Hi Everyone,
Ran into an interesting case last night, and I was hoping that someone
on the list here could give me some guidance.
I''ve got a Polymorphic association for Addresses (which can belong to
two different models).
The catch is, one model requires a strict, precise address, and the
other only requires a City, State and Postal Code.
I want to use :validates_presence_of :street,
2006 Jun 19
3
Parent Child form using Partials
I am trying to make a simple application which consists of contacts and
their addresses.
class Contact < ActiveRecord::Base
has_many :addresses
end
class Address < ActiveRecord::Base
belongs_to :contact
end
I would like to be able to edit/add addresses from within the edit/add
of the contact. I scaffolded the contact and address objects and
modified the contacts/_form partial as
2006 Jun 01
3
more questions: human_name
One more question:
Is there some way to set the human_name of a column? e.g.: human_name
for column address1 shouldn''t be Address1 but "Address, line 1".
If not, should I make a hash with my custom names?
Best regards,
--
----------------------------------------------------------------------
Yannick Majoros http://www.inma.ucl.ac.be/~majoros
Informaticien UCL/INMA-MEMA
2006 Aug 15
5
Ferret Segmentation Faults
Hi,
I am getting a number of segmentation faults using Ferret 0.9.5, Fedora
Core 5 and Ruby 1.8.4
I installed it with the recommended gem install ferret
and example segmentation fault creation line would be as follows:
@records = FerretConfig::INDEX.search("address_line_2:\"Dumbarton\"")
I am also using acts_as_ferret and rails 1.15 but think this is an issue
with
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 -
2008 Jul 07
0
ActiveRecord in Rails 2.1.0 misbehaving for Aggregate Attr.
I am not sure if this is a bug in ActiveRecord or is this the intended
behavior. If it is then it does not make sense to me.
In a nutshell: If you change an aggregate object attribute created via
composed_of method (see Agile Web Development - Second Edition Chapter
17 page 313 onwards) and then save the model, the change to the model
(composite attribute specifically) will not be saved UNLESS
2009 Mar 10
0
autosave no longer a valid option for belongs_to?
The Rails API doc (api.rubyonrails.org) says that :autosave is still a
valid option for belongs_to in the latest version of Rails. However, a
look at the activerecord/lib/active_record/associations.rb (line 1590)
reveals that it is not in the @@valid_keys_for_belongs_to_association
array. I also noticed that it''s not in the ActiveRecord API doc
(ar.rubyonrails.org).
Does anyone have any