Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: [Nitro] Discussion about setting relationships with unsaved objects: msg#00320

lang.ruby.nitro.general

Subject: Re: [Nitro] Discussion about setting relationships with unsaved objects

Makes sense to me.
---
http://www.infurious.com


On 22/02/2006, at 9:23 PM, Rob Pitt wrote:

> Currently in Og if you try and assign has many or joins many
> relationships to an unsaved object, the object is silently saved in
> the
> background (this is needed to make the relationship work), but if
> you do
> the same with refers_to/belongs_to/has_one, this does not happen,
> instead Og proceeds as if everything is fine essentially ignoring your
> request (and losing the relationship).
>
> I think all of these behaviours are wrong because you may not expect
> your object to have been saved in the has_many/joins_many case and you
> will not know why your code mysteriously breaks in the belongs_to case
> (this actually bit me while writing a unit test the other day and it
> took me a good five minutes to work out what was wrong).
>
> I believe that all of these cases should throw and exception as you
> should not be trying to assign relationships to unsaved objects, but
> before I make this happen I want to confirm with the list you agree
> this
> is the appropriate course of action. This way informs you that your
> code
> is broken and if you did want automatic saving all you'd need to do
> is:
>
> begin
> obj.relation = remote
> rescue UnsavedException
> obj.save!
> remote.save!
> retry
> end
>
> Of course, this is pretty silly since you should be doing:
>
> remote.save!
> obj.relation = remote
> obj.save!
>
> In your code anyway.
>
> At the very least, the refers_to/has_one/belongs_to relationships
> should
> have the same behaviour as the other relationships, be that auto-
> saving
> as they currently do, or as I believe, throwing exceptions.
>
> Comments?
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general@xxxxxxxxxxxxx
> http://rubyforge.org/mailman/listinfo/nitro-general
>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qplus.devel/200...    network.jabber....    debian.qa-packa...    encryption.gpg....    python.dabo.dev...    uclinux.devel/2...    science.mathema...    recreation.pesc...    kernel.ck/2004-...    mozilla.devel.e...    tex.latex.prosp...    ietf.multi6/200...    bbc.cvs/2002-11...    xfree86.newbie/...    jakarta.taglibs...    altlinux.hardwa...    comedi/2002-05/...    horde.bugs/2004...    games.diplomacy...    finance.e-gold....    web.dom.test-su...    lang.ruby.rails...    os.netbsd.devel...    video.gstreamer...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation